Biggest issue I've found is the Command key is a bad jump key. Cause when I move and jump, it flips my screen into Dash Board.
I'm still trying to recreate the bug you experienced.
Edit: I can see it. Hmm. I'm going to have to do a screen recording and slow it down to take a closer look.
Video: http://cl.ly/2G3Y07080R3B (http://cl.ly/2G3Y07080R3B)
So strange.If you move too fast the bug doesn't happen. If you move just slow enough.... he skips to the left. Interesting.
Edit 2: I've pinpointed the bug. It is in this chunk:
IF xvel(obj) < 0 THEN
//left
LET nextx = ( xpos(obj)+xvel(obj) )
FOR n = 0 to 1
LET nexty = ( ypos(obj) + (sizey(obj)*n) ) -(1*n)
LET cp$(5+n) = maptile$(mapx(nextx),mapy(nexty))
IF cp$(5+n) = "1" THEN //
LET xvel(obj) = 0
LET xpos(obj) = mapx(xpos(obj))*32-32
END IF //
NEXT
END IF
Now if I comment these two lines, the game appears to play the same, but without that jumping:
IF xvel(obj) < 0 THEN
//left
LET nextx = ( xpos(obj)+xvel(obj) )
FOR n = 0 to 1
LET nexty = ( ypos(obj) + (sizey(obj)*n) ) -(1*n)
LET cp$(5+n) = maptile$(mapx(nextx),mapy(nexty))
IF cp$(5+n) = "1" THEN //
//LET xvel(obj) = 0
//LET xpos(obj) = mapx(xpos(obj))*32-32
END IF //
NEXT
END IF
I'd like you to run the program, and then comment out the following in the method " drawmap " and tell me why this makes it draw all tiles 1 square beneath.
IF maptile$(x,y-1) = "1" then
LET sprite$ = "above"
END IF
Fixed!
Turned out to be a problem involving how SilverCreator handles global variables.
This is your code:
LET sprite = 1
LET windowTXT$ = "Start"
FOR x = 1 to 25
FOR y = 1 to 18
LET pic$ = maptile$(x, y)
IF pic$ = "1" then
LET sprite$ = "neither"
IF maptile$(x,y-1) = "1" then
LET sprite$ = "above"
END IF
CREATESPRITE sprite, sprite$
MOVESPRITE sprite, x*32-32, y*32-20, TRUE
LET sprite = sprite + 1
END IF
NEXT
NEXT
Notice how you call maptile$(x, y-1)?
Now look at the maptile method code:
IF x < 26 then
IF x > 0 then
IF y < 19 then
IF y > 0 then
LET tile$ = NTHFIELD$(map$(y), ",", x)
RETURN tile$
END IF
END IF
END IF
END IF
The problem is that all variables in Sc are global. And cause in Sc you have X and Y as parameters for this method, when you call maptile$(x, y-1), you are setting x = x and y = y - 1.
That is why there is that offset!
Easy fix, just change the method to this:
(http://cl.ly/image/092i0s2M120Z/Screen%20Shot%202012-08-24%20at%204.31.41%20PM.png)
Use different non-used variables for the parameters. x1 instead of x, and y1 instead of y.
Your code was right on for the most part.
I just made two variables:
LET cameraX = xpos(player) - 500
LET cameraY = ypos(player) - 300
MOVESPRITE object, x - cameraX, y - cameraY
This is the magic code that makes the universe revolve around the player. You can constrain with if statements:
IF cameraX > 500 THEN cameraX = 500