Understanding the language, error messages, etc.
by Sushi » Thu Dec 18, 2014 12:28 am
I'm a newblet of a programmer, and need help understanding how a scroller is constructed. I'm trying to create something similar to UFO race in which you map a bitmap to a value in an array. I'm also trying to figure out how to move the the map in a variable direction, not just left right up and down. I don't really know the formulas. Can anybody explain it to me?
-
Sushi
-
- Posts: 52
- Joined: Tue Oct 07, 2014 12:12 am
by ajsb113 » Thu Dec 18, 2014 3:03 pm
The way that I've done it is similar to the way Rodot did in UFO race. Have two ints cameraX and cameraY. If you're roaming on a map you can do this:
- Code: Select all
cameraX = player.x - LCDWIDTH/2;
cameraY = player.y - LCDHEIGHT/2;
That should put the camera position to the top left of the screen and to draw:
- Code: Select all
gb.display.drawBitmap(player.x - cameraX, player.y - cameraY, bitmap);
By subtracting camera value it will draw everything relative to the screen and the player, so the map will move with the player. I hope this helps
-
ajsb113
-
- Posts: 45
- Joined: Tue Jun 24, 2014 4:47 am
- Location: Illinois, United States
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 62 guests