Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Charlie

#1
Thanks :)
#2
OK thanks..I just realized I guess you have to have a paid subscription to be able to compile to the iphone right?
#3
does GLBasic work for ios 5? I compiled a simple Hello World app and the code failed to compile in xcode.
#4
Haha thanks Slydog. I was wrecking my brain over an obvious error. You were correct in that:

Code (glbasic) Select
FOR y = 0  TO tilesDown +1
  FOR x = 0  TO tilesAcross +1
    IF map[x][y][1].tile <> 0
      DRAWSPRITE map[x + tileAddX][y + tileAddY][1].tile, (x*tileSize) + ScrollAmountX, (y*tileSize) + ScrollAmountY
    ENDIF
  NEXT
NEXT


the if statement need the tileAddX and tileAddY added to the x and y as well.
tileAddX and tileAddY do in fact keep up with the number of tiles that have been scrolled. I started with a static map and later forgot about adding the offsets in there. Just couldn't catch it lol.

Oh, and it already only draws the tiles that are onscreen. tilesDown and tilesAcross are the number of tiles on screen (based on screen resolution).

Quote from: bigsofty on 2011-May-29
I don't think it has anything to do with blank tiles, the vars ScrollAmountX and           ScrollAmountY are being continuously reset to -48. This may be the cause of your jerking.

This was fine. (I understand I didn't explain what any of my variables do lol)...This enables smooth per pixel scrolling as opposed to tile by tile scrolling. Once it reaches a certain point it adds or subtracts a tile offset value to tileAddX and tileAddY and then it resets.

This isn't my first time doing a tile map...I just didn't catch my error and needed another eye. Thanks again.
#5
my "simple" solution is to draw a white tile on the blank positions (white being transparent in my game) ...they will not show through but this is not very efficient lol
#6
I'm drawing tile maps stored in a 3 dimensional array. Third dimension is for added layers.
It is drawing fine and scrolling fine, as long as every tile in the map is assigned an image tile.
But if I leave a map position blank "0", then when the tile map scrolls, the blank portions jerk and never scroll off the screen while the rest of the map does.
Below is my drawing and scrolling code. Any ideas?

Code (glbasic) Select
//MAIN GAME LOOP

WHILE KEY(01) = FALSE

//Draw Tile Map
FOR y = 0  TO tilesDown +1
FOR x = 0  TO tilesAcross +1
IF map[x][y][1].tile <> 0
DRAWSPRITE map[x + tileAddX][y + tileAddY][1].tile, (x*tileSize) + ScrollAmountX, (y*tileSize) + ScrollAmountY
ENDIF
NEXT
NEXT


//Go Right
IF KEY(32) OR KEY(205)
ScrollAmountX = ScrollAmountX - 2
IF ScrollAmountX < tileSize - (tileSize * 2)
ScrollAmountX = 0
tileAddX = tileAddX + 1
ENDIF
ENDIF

//Go Left
IF KEY(30) OR KEY(203)
IF tileAddX > 0
ScrollAmountX = ScrollAmountX + 2
ENDIF
ENDIF

IF ScrollAmountX > 0
ScrollAmountX = -48
IF tileAddX > 0
tileAddX = tileAddX - 1
ENDIF
ENDIF

//Go Up
IF KEY(31) OR KEY(208)
ScrollAmountY = ScrollAmountY - 2
IF ScrollAmountY < tileSize - (tileSize * 2)
ScrollAmountY = 0
tileAddY = tileAddY + 1
ENDIF
ENDIF

//Go Down
IF KEY(17) OR KEY(200)
IF tileAddY > 0
ScrollAmountY = ScrollAmountY + 2
ENDIF
ENDIF

IF ScrollAmountY > 0
ScrollAmountY = -48
IF tileAddY > 0
tileAddY = tileAddY - 1
ENDIF
ENDIF


SHOWSCREEN


WEND
#7
my reason for using arrays this way was for a "visual" for using tile maps. That way you can see a visual of your map using image numbers.
Most languages can do this with arrays.

Example:
image 1 = grass 2 = dirt

array[5][5] = {
1,2,1,1,1
1,2,1,1,1
1,2,2,2,2
1,1,1,1,1
1,1,1,1,1
}
#8
is it possible to declare multi-dimensional arrays in glbasic like in other languages such as:

array[4][3] = { 1,2,3,4,
              1,2,3,4,
              1,2,3,4 }