Sun Jan 18, 2015 6:05 pm
Sun Jan 18, 2015 6:39 pm
volatile int player playerstand //change this to his standing pose's name
volatile int player.x 20 //this is the starting point
volatile int player.y 20 //starting point
volatile int player.flip NOFLIP //saying that he is facing left
void loop() {
gb.display.drawBitmap(player,player.x,player.y,NOROT,player.flip); //draws player forever
player == playerstand;
if (gb.buttons.repeat(BTN_LEFT,1)) { //If they press left
player.flip == NOFLIP
player.x -= 1; //go left
if (player == playerstand) { //from || to /\
player == playerwalk1;
}
if (player == playerwalk1) { //from /\ to |
player == playerwalk2;
}
if (player == playerwalk2) { //from | to /\
player == playerwalk1;
}
}
if (gb.buttons.repeat(BTN_RIGHT,1)) { //If they press right
player.flip == FLIPH;
player.x += 1; //go right
if (player == playerstand) {
player == playerwalk1;
}
if (player == playerwalk1) {
player == playerwalk2;
}
if (player == playerwalk2) {
player == playerwalk1;
}
}
Sun Jan 18, 2015 7:04 pm
DrWhoCares wrote:Question 1:
I want to display an image as a background that will never change over the course of gameplay. This image is not made up of pure rectangles and instead has points where it may be crooked or jagged. How do I go about doing this? How do I store it?
Question 2:
I have a player sprite that I want to display, easy enough. However, while he's running I want it to loop through running animations, how can I create a sort of "sprite sheet" and run through multiple different states. (A state machine is easy, the actual bitmap changing is the problem.)
Info:
Been looking at some code, but none of it quite answers my questions or works the same way. That, or it's just too alien to me.
Thanks.
Sun Jan 18, 2015 7:09 pm
Sun Jan 18, 2015 7:17 pm
Mon Jan 19, 2015 3:25 am
Mon Jan 19, 2015 5:13 am
const byte PROGMEM playerSprite[] =
{
8,8
B00111100
B00100100
B00100100
B01111100
B11111100
B11111100
B11001100
B11101110
}
const byte PROGMEM playerSprite[] =
{
{8,6, 0x78, 0x50, 0x78, 0xFC, 0x78, 0xCC,}
} //standing
const byte ani_list[][8] PROGMEM =
{
{1, 2, 3, 4, 5, 6, 7, 8}, <<<<<<<<<<<<-------- //running animation
};
Mon Jan 19, 2015 6:02 am
Mon Jan 19, 2015 6:09 am
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
const byte player[][8] PROGMEM =
{
{8,8,0x3C,0x24,0x24,0x7C,0xFC,0xFC,0xCC,0xEE}, //Standing
{8,8,0x3C,0x24,0x24,0x7C,0xFC,0xFC,0x6C,0xCC}, //Running A
{8,8,0x3C,0x24,0x24,0x7C,0xFC,0xFC,0xCC,0xD8} //Running B
};
byte playerX = 0;
byte playerY = 0;
byte player_CurrentState = 0;
byte player_Facing = 1;
void setup()
{
gb.begin(); //REQUIRED
gb.titleScreen(F("Jumpin' Guy")); //SETUP TITLE SCREEN (F("text", logoVar))
playerX = 10;
playerY = 10;
}
void loop()
{
if( gb.update() ) {
byte flip = NOFLIP;
if( player_Facing == -1 ) {
flip = FLIPH;
}
gb.display.drawBitmap(playerX, playerY, player[player_CurrentState], NOROT, flip);
//Movement Checks (CRUDE)
if(gb.buttons.pressed(BTN_C)) {
gb.titleScreen(F("Jumpin' Guy"));
}
if( gb.buttons.repeat(BTN_RIGHT, 1) ) {
player_CurrentState = 1;
playerX++;
gb.display.drawBitmap(playerX, playerY, player[player_CurrentState], NOROT, flip);
player_CurrentState = 2;
gb.display.drawBitmap(playerX, playerY, player[player_CurrentState], NOROT, flip);
} else if( gb.buttons.repeat(BTN_LEFT, 1) ) {
player_Facing = -1;
flip = FLIPH;
player_CurrentState = 1;
playerX--;
gb.display.drawBitmap(playerX, playerY, player[player_CurrentState], NOROT, flip);
player_CurrentState = 2;
gb.display.drawBitmap(playerX, playerY, player[player_CurrentState], NOROT, flip);
} else {
player_CurrentState = 0;
player_Facing = 1;
gb.display.drawBitmap(playerX, playerY, player[player_CurrentState], NOROT, flip);
}
}
}
Mon Jan 19, 2015 6:40 am
const byte player[][8] PROGMEM =
{8,8,0x3C,0x24,0x24,0x7C,0xFC,0xFC,0xCC,0xEE}, //Standing
const byte player[][10] PROGMEM =