Re: Newb at game making Sprite and game map developing
Posted: Tue Aug 02, 2016 5:56 am
OK I put everything together and it compiles but I'm still getting flicker from the tilemap and sever speeds right or left to the boundary but up and down move correctly. I cant really tell if the player sprites are working correctly.
I went ahead and made a few terrain sprites extra for adding extra rooms and included them in the sketch. Not having to save all those huge bitmaps looks like it might be cheaper in the end which means more maps in a single program I say with fingers crossed
Edit: made a couple corrections player sprites stop with correct orientation but still zooms left and right and tilemap flickers. I can't figure out what I did to make it do that.
Edit 2: fixed my player sprites to 6,6, instead of 8,6. Don't know why I had them like that. Glitches still persist
I went ahead and made a few terrain sprites extra for adding extra rooms and included them in the sketch. Not having to save all those huge bitmaps looks like it might be cheaper in the end which means more maps in a single program I say with fingers crossed
- Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
const byte tilemap[] PROGMEM = {14,8,
6,6,
3,3,3,3,3,3,6,6,3,3,3,3,3,3,
3,3,3,5,3,6,6,6,3,3,3,3,3,3,
3,3,6,6,6,6,6,6,6,3,3,3,3,3,
3,6,6,6,6,6,6,6,6,6,3,3,3,3,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,
3,3,6,6,6,6,6,6,6,6,6,6,3,3,
3,3,6,6,6,6,6,6,6,6,6,6,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,3};
const byte bush_bottom[] PROGMEM = {6,6,0x48,0x30,0x58,0x00,0x00,0x00,};
const byte bush_top[] PROGMEM = {6,6,0x00,0x00,0x00,0x30,0x48,0xb4,};
const byte bush[] PROGMEM = {6,6,0x30,0x48,0xb4,0x48,0x30,0x58,};
const byte rock_terrain[] PROGMEM = {6,6,0x48,0xa4,0x14,0xa0,0x84,0x50,};
const byte turtle_rock[] PROGMEM = {6,6,0x48,0xa4,0x14,0xa0,0x84,0x50,};
const byte port_noir[] PROGMEM = {6,6,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,};
const byte port_blanc[] PROGMEM = {6,6,0x00,0x00,0x00,0x00,0x00,0x00,};
const byte *spritesheet[] = {bush_bottom,bush_top,bush,rock_terrain,turtle_rock,port_noir,port_blanc};
const byte sever_front_1[] PROGMEM = {6,6,0x78,0x0,0x0,0x30,0x0,0xcc,};
const byte sever_front_2[] PROGMEM = {6,6,0x84,0x48,0x78,0x84,0x78,0x0,};
const byte sever_left_1[] PROGMEM = {6,6,0x78,0x80,0xc8,0xb4,0x0,0xcc,};
const byte sever_left_2[] PROGMEM = {6,6,0x4,0x58,0x30,0x0,0x78,0x0,};
const byte sever_rear_1[] PROGMEM = {6,6,0X78,0X78,0X0,0X30,0X0,0XCC,};
const byte sever_rear_2[] PROGMEM = {6,6,0x84,0x0,0x78,0x84,0x78,0x0,};
const byte sever_right_1[] PROGMEM = {6,6,0x78,0x4,0x4c,0xb4,0x0,0xcc,};
const byte sever_right_2[] PROGMEM = {6,6,0x80,0x68,0x30,0x0,0x78,0x0,};
int player_x = 15;
int player_y = 15;
int player_direction = 0;
int x=0,y=0;
void setup() {
gb.begin();
gb.titleScreen(F("test"));
gb.display.persistence = false;
}
void loop() {
if(gb.update()){
if (gb.buttons.repeat(BTN_RIGHT,1));
if (gb.buttons.repeat(BTN_LEFT,1));
if (gb.buttons.repeat(BTN_DOWN,1));
if (gb.buttons.repeat(BTN_UP,1));
gb.display.drawTilemap(x,y,tilemap,spritesheet); // draw the tilemap
// gb.display.cursorY = 12; gb.display.println( x );gb.display.println( y );
if(gb.buttons.repeat(BTN_UP,1)){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_rear_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_rear_2);
}
player_direction = 1;
player_y = player_y - 1;}
if(player_y <= 0){
player_y = 0;}
if(gb.buttons.repeat(BTN_DOWN,1)){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_front_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_front_2);
}
player_direction = 2;
player_y = player_y + 1;}
if(player_y >= 40){
player_y = 40;}
}
if(gb.buttons.repeat(BTN_RIGHT,1)){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_right_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_right_2);
}
player_direction = 3;
player_x = player_x + 1;}
if(player_x >= 77){
player_x = 77;}
if(gb.buttons.repeat(BTN_LEFT,1)){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_left_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_left_2);
}
player_direction = 4;
player_x = player_x - 1;}
if(player_x <= -2){
player_x = -2;}
////////////PLAYER DIRECTION/////////////
if (player_direction == 1){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_rear_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_rear_2);
}
}
else if (player_direction == 2){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_front_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_front_2);
}
}
else if (player_direction == 3){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_left_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_left_2);
}
}
else if (player_direction == 4){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_right_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_right_2);
}
}
else {
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_front_1);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_front_2);
}
}
}
Edit: made a couple corrections player sprites stop with correct orientation but still zooms left and right and tilemap flickers. I can't figure out what I did to make it do that.
Edit 2: fixed my player sprites to 6,6, instead of 8,6. Don't know why I had them like that. Glitches still persist