Newb at game making Sprite and game map developing

Understanding the language, error messages, etc.

Re: Newb at game making Sprite and game map developing

Postby Duhjoker » Sat Jul 30, 2016 10:04 pm

Aweome you rock!!!!! I will look at that shortly.

I use the piskel online bitmap editor. It has all kinds of features for copying and pasting changing pixel colors and saves them as .png.

Ok I'm still having trouble displaying my sever sprite.i went ahead and changed my bitmap using paint to save it with white tiles and exchanged the room bitmap with the updated bitmap. I think its a color issue but i still have the color all mixed up and don't know which to change.

heres the code i added a logo screen but unsure how to add it.

Code: Select all


#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

const byte logo[] = {88,48,
0xfe,0xef,0x7f,0xff,0xff,0xff,0xff,0xff,0xef,0xdf,0xf0
,0xf6,0xdf,0xbf,0xff,0xff,0xff,0xff,0xff,0xdf,0xff,0x70
,0xf7,0xbb,0xbf,0xff,0xff,0xff,0xff,0xff,0xdd,0xef,0xf0
,0xef,0x77,0x71,0x51,0xdd,0x74,0x57,0xfc,0xee,0xf7,0x70
,0xfe,0xfe,0xfb,0x57,0xc9,0x26,0xd7,0xfb,0xf7,0x7f,0xb0
,0x7d,0xbe,0xfb,0x13,0xd5,0xde,0xc7,0x89,0xf6,0xf7,0x70
,0xb3,0xdd,0xfb,0x57,0xdd,0xde,0xd7,0xab,0xfb,0xeb,0xf0
,0xcf,0xf7,0xfb,0x51,0xdd,0xde,0xd7,0x8b,0xfc,0xbd,0xe0
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x10
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0
,0xff,0x8f,0x03,0x88,0xe1,0xc1,0xc3,0xbf,0x0f,0x9f,0xf0
,0xff,0xb6,0xfd,0x77,0x5e,0xbe,0xbd,0x5e,0xf7,0x6f,0xf0
,0xff,0x6d,0xe1,0x7f,0x51,0xa2,0xa3,0x5e,0xfa,0xf7,0xf0
,0xf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ff,0x5d,0x70
,0x79,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x79,0xe0
,0xa6,0x9f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xa6,0x90
,0xa6,0x9a,0x69,0xff,0xff,0xe9,0xa6,0x9a,0x69,0xa6,0x90
,0x59,0x65,0x96,0xff,0xff,0xd6,0x59,0x65,0x96,0x59,0x60
,0xeb,0xae,0xba,0xff,0xff,0xfa,0xeb,0xae,0xba,0xeb,0xa0
,0x5d,0x75,0xd7,0x55,0x55,0x57,0x5d,0x75,0xd7,0x5d,0x70
,0x79,0xe7,0x9e,0xaa,0xaa,0x9e,0x79,0xe7,0x9e,0x79,0xe0
,0xa6,0x9a,0x69,0xff,0xff,0xe9,0xa6,0x9a,0x69,0xa6,0x90
,0xa6,0x9a,0x69,0xaa,0xaa,0xa9,0xa6,0x9a,0x69,0xa6,0x90
,0x59,0x65,0x97,0x55,0x55,0x56,0x59,0x65,0x96,0x59,0x60
,0xeb,0xae,0xba,0x7f,0xff,0xfa,0xeb,0xae,0xba,0xeb,0xa0
,0x5d,0x75,0xd7,0xaa,0xaa,0x97,0x5d,0x75,0xd7,0x5d,0x70
,0x79,0xe7,0x9e,0x55,0x55,0x5e,0x79,0xe7,0x9e,0x79,0xe0
,0xa6,0x9a,0x69,0x7f,0xff,0xe9,0xa6,0x9a,0x69,0xa6,0x90,};

const byte PROGMEM room_1[] = {88,48,
0x59,0x65,0x96,0x59,0x60,0x00,0x59,0x65,0x96,0x59,0x60
,0xa6,0x9a,0x69,0xa6,0x90,0x00,0xa6,0x9a,0x69,0xa6,0x90
,0x14,0x51,0x45,0x14,0x50,0x00,0x14,0x51,0x45,0x14,0x50
,0xa2,0x8a,0x28,0xa2,0x80,0x00,0xa2,0x8a,0x28,0xa2,0x80
,0x86,0x18,0x61,0x86,0x10,0x00,0x86,0x18,0x61,0x86,0x10
,0x59,0x65,0x96,0x59,0x60,0x00,0x59,0x65,0x96,0x59,0x60
,0x59,0x65,0x80,0x58,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0xa6,0x9a,0x40,0xa4,0x00,0x00,0x00,0x00,0x00,0xa6,0x90
,0x14,0x51,0x40,0x14,0x00,0x00,0x00,0x00,0x00,0x14,0x50
,0xa2,0x8a,0x00,0xa0,0x00,0x00,0x00,0x00,0x00,0xa2,0x80
,0x86,0x18,0x40,0x84,0x00,0x00,0x00,0x00,0x00,0x86,0x10
,0x59,0x65,0x80,0x58,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0x59,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0xa6,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa6,0x90
,0x14,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x50
,0xa2,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x80
,0x86,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x86,0x10
,0x59,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa6,0x90
,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x50
,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x80
,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x86,0x10
,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x59,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0xa6,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa6,0x90
,0x14,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x50
,0xa2,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x80
,0x86,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x86,0x10
,0x59,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0x59,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0xa6,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa6,0x90
,0x14,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x50
,0xa2,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x80
,0x86,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x86,0x10
,0x59,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x60
,0x59,0x65,0x96,0x59,0x65,0x96,0x59,0x65,0x96,0x59,0x60
,0xa6,0x9a,0x69,0xa6,0x9a,0x69,0xa6,0x9a,0x69,0xa6,0x90
,0x14,0x51,0x45,0x14,0x51,0x45,0x14,0x51,0x45,0x14,0x50
,0xa2,0x8a,0x28,0xa2,0x8a,0x28,0xa2,0x8a,0x28,0xa2,0x80
,0x86,0x18,0x61,0x86,0x18,0x61,0x86,0x18,0x61,0x86,0x10
,0x59,0x65,0x96,0x59,0x65,0x96,0x59,0x65,0x96,0x59,0x60,};


const byte sever_front[] PROGMEM = {6,6,
B111111,
B010010,
B011110,
B101101,
B011110,
B110011,};



void setup() {
  // put your setup code here, to run once:
   gb.begin();
   gb.titleScreen(F("Myth of esmerelda"));
}

void loop() {
  // put your main code here, to run repeatedly:
   if(gb.update()){
    gb.display.setColor(INVERT);{
    gb.display.drawBitmap(0,0,room_1);
   }
   gb.display.setColor(BLACK);{
   gb.display.drawBitmap(1,1,sever_front);
   
   }
   gb.display.setColor(WHITE);{
   }
   }
}
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Newb at game making Sprite and game map developing

Postby naed » Sat Jul 30, 2016 10:19 pm

i only ever use two colours when creating a sprite - black and white, this ensures it it encoded correctly

if you want grey colours adding to your sprite you would draw them in black/white first, then encode them then your code would tell the gamebuino to display it as grey

I think you have some other colours when creating your sprite and this is stopping you encoding it correctly

i can also see you have inverted the colours of your map on the above post - you shouldn't need to do this and it is just a waste of code and messy, I already posted correctly encoded code for your map that doesn't require any modification to be displayed
User avatar
naed
 
Posts: 140
Joined: Tue May 31, 2016 3:18 pm

Re: Newb at game making Sprite and game map developing

Postby Duhjoker » Sat Jul 30, 2016 10:33 pm

Ok thank you!!!
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Newb at game making Sprite and game map developing

Postby naed » Sat Jul 30, 2016 10:57 pm

ok, I've been playing around with this and have a question myself that i cannot figure out, can anyone point me in the right direction?

if Duhjoker uses one big sprite as the background, how can we detect collisions with his rocks (as they are part of the full screen sprite)

would it be easier to create a tilemap for the rooms, and also would this be easier to create collision detection?

i created the tilemap no problems, but playing around with the following didn't get me the intended results

Physics:

gb.collidePointRect(x1,y1,x2,y2,w,h)
gb.collideRectRect(x1,y1,w1,h1,x2,y2,w2,h2)
gb.collideBitmapBitmap(x1, y1, b1, x2, y2, b2)
User avatar
naed
 
Posts: 140
Joined: Tue May 31, 2016 3:18 pm

Re: Newb at game making Sprite and game map developing

Postby Duhjoker » Sun Jul 31, 2016 6:59 am

EDITED:::::

Programmed black and grey player sprites correctly. Setting frame rate to anything above 60 FPS to look good. But there is a skip about every 20 frames that makes it look funny no mater what speed. But I can deal with it though.

Ok on your movement exampl I understand that X and Y and vX and Vy are coordinates in space or on screen as it is. How do you get the integers in the brackets or what do they mean?

Also how can I add orientation to the movements? I know player.orientation= but are the integers the numbers of the sprites after doing [num_sprites]? And would I do it once for each color? Do i also need to do a gb.display for each orientation and color?


Please don't forget to read Naeds post above any one with knowledge of the collision variables.
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Newb at game making Sprite and game map developing

Postby naed » Sun Jul 31, 2016 11:47 am

your movement exampl I understand that X and Y and vX and Vy are coordinates in space or on screen as it is. How do you get the integers in the brackets or what do they mean?


Which part are you referring to?


EDIT

after lots of searching and reading about collision data i think i may have sorted out the collision part of the code

let me get to my pc a bit later and i'll post an update here if i get it to work
User avatar
naed
 
Posts: 140
Joined: Tue May 31, 2016 3:18 pm

Re: Newb at game making Sprite and game map developing

Postby Duhjoker » Sun Jul 31, 2016 10:09 pm

ok here is part of what you gave me.......

Code: Select all
    if(gb.buttons.repeat(BTN_UP,1)){
      player_y = player_y - 1;}
    if(player_y <= 0){     //////////// what are these integers, how are they calculated   
      player_y = 0;}          //////////// what are these integers, how are they calculated

    if(gb.buttons.repeat(BTN_DOWN,1)){
      player_y = player_y + 1;}
    if(player_y >= 40){      //////////// what are these integers, how are they calculated
      player_y = 40;}       //////////// what are these integers, how are they calculated

    if(gb.buttons.repeat(BTN_RIGHT,1)){
      player_x = player_x + 1;}
    if(player_x >= 77){    //////////// what are these integers, how are they calculated
      player_x = 77;}       //////////// what are these integers, how are they calculated

    if(gb.buttons.repeat(BTN_LEFT,1)){
      player_x = player_x - 1;}
    if(player_x <= -2){   //////////// what are these integers, how are they calculated
      player_x = -2;}    ///////////// what are these integers, how are they calculated

  }
}


I added comments to the parts I was asking about.

Also on adding sprite orientation how would write the prameters to display a sprite when hes looking or being told which direction to go and then add it to the controls?

Code: Select all
    gb.display.drawBitmap(player_x,player_y,player);

User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Newb at game making Sprite and game map developing

Postby naed » Sun Jul 31, 2016 10:58 pm

Code: Select all
if(gb.buttons.repeat(BTN_UP,1)){
      player_y = player_y - 1;}
    if(player_y <= 0){     //////////// If player co-ords equal less than or equal to zero (zero being the edge of the screen)
      player_y = 0;}          //////////// Make player co-ords zero (bring player back intob the screen


The integers are simply there to set the bounties to the edge of the gamebuinos screen

To make your player sprite change direction you could simply add the displayBitmap function under the direction controls for each of your sprites

Code: Select all
if(gb.buttons.repeat(BTN_UP,1)){
gb.display.drawBitmap(player_x,player_y,sprite_up);
}


I haven't tested this but don't see why it wouldn't work
User avatar
naed
 
Posts: 140
Joined: Tue May 31, 2016 3:18 pm

Re: Newb at game making Sprite and game map developing

Postby Duhjoker » Sun Jul 31, 2016 11:43 pm

Oh OK!!! Thank you!!!

Looks simple enough I'll make a copy of the current build and play with it. Also don't they need the vertical coordinates Or the VX VY on a couple?
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Newb at game making Sprite and game map developing

Postby Duhjoker » Mon Aug 01, 2016 4:04 am

I'm learning yay!!!!! At least I think I am.

Just now got around to booting up my laptop to try adding a different set of sprites to each control direction and it works but I removed the first gb.display.drawbitmap() from the beginning thinking the character would face the last direction but it doesn't work that way I see now and because I removed the first set of code you only see it when pressing a direction.

Easy fix but it presents a new question how can I make the player sprite stay in the direction of the last button pushed.

I also had a question regarding the light sensor. I remember that besides the d-pad buttons LOZ requires 4 more buttons. A, B, select and start to use certain features of the game. Like the start menu to change items and to save and what not. I was thinking at some point that we coulkd utilize that component to create an extra button. Where you could hold your finger over it to make it see dark and hold a certain d-pad direction as a failsafe so its not done accidently.
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

PreviousNext

Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 16 guests

cron