Help Wanted

Baffling Coding Problem – Ereon

Ereon

Member

Posts: 1018
From: Ohio, United States
Registered: 04-12-2005
This is the movement portion of the code from my new mini-game that I've been working on.


playercontrol:
IF INKEY$()="w"
move object 1,2
IF sound playing(1)=0 THEN play sound 1
ENDIF

IF INKEY$()="s"
move object 1,-2
IF sound playing(1)=0 THEN play sound 1
ENDIF

IF INKEY$()="a"
move object left 1,1
IF sound playing(1)=0 THEN play sound 1
ENDIF

IF INKEY$()="d"
move object right 1,1
IF sound playing(1)=0 THEN play sound 1
ENDIF

IF INKEY$()="" THEN stop sound 1

px#=px#+mousemovey()/3
py#=py#+mousemovex()/3
xrotate camera px#
yrotate camera py#
yrotate object 1,py#

posx#=object position x(1)
posy#=object position y(1)
posz#=object position z(1)

IF posx#> 200 THEN DEC posx#,400:goto skip
IF posx#<-200 THEN INC posx#,400:goto skip
IF posz#> 200 THEN DEC posz#,400:goto skip
IF posz#<-200 THEN INC posz#,400:goto skip
skip:
Position Object 1,posx#,posy#,posz#

position camera 0,object position x(1),10,object position z(1)
Position Sound 1,object position x(1),10,object position z(1)
Position Sound 2,object position x(1),10,object position z(1)

return

It's a Sub written in DarkBASIC, and it's supposed to move the player and, if he moves outside the tile, loop him around to the other end to give the illusion of infinite space, like this.

But instead it keeps teleporting the player to all kinds of different, apparently meaningless, positions; it even changes the y coordinate when the only one over 200 if the x coordinate, which I didn't code it to do at all. I'm at the point of writing my own movement code from scratch and bypassing the built in functions altogether, but I wanted to check here first and see if anyone had any kind of other solution before I tried something so drastic and possibly annoying.

------------------

The time for speaking comes rarely, the time for being never departs.
George Macdonald