Gamebuino Advanced prototype has been built

Show us your Gamebuino clone or the last module you made.

Re: Gamebuino Advanced prototype has been built

Postby Duhjoker » Sun Jun 04, 2017 1:14 am

Ok so I was having a problem using Rodots button library so I've been learning how to use the bounce library as it works best with the teensy3.x. I'm kind of reeling on how fast I figured this all out. After doing many tests to make sure the buttons were working I started adding stuff in.

I need to make a header file at some point but I have the controls set up now using bounce. I had a lil trouble with a repeat function but it was really simple to fix.

Unfortunately that brings us back to the insanity of fixing a few graphical issues. For instance and I've known about since I first loaded a sketch to my teensy. When the character moves he leaves a tron light cycle trail. But he can walk through it lol.

This might be fixed with tiles up though. Ok I'll post the new demo shortly.

Code: Select all
#include <SPI.h>
#include <Grafx.h>
#include <SD.h>
#include <Bounce.h>

/*
Teensy3.x and Arduino's
You are using 4 wire SPI here, so:
 MOSI:  11//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
 MISO:  12//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
 SCK:   13//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
ESP8266-----------------------------------
Use:
#define __CS  16  //(D0)
#define __DC  5   //(D1)
#define __RST 4   //(D2)

 SCLK:D5
 MOSI:D7
 */
 
#define __CS1    10
#define __DC    9
#define SD_CS 4
#define BUFFPIXEL 20

/*
Teensy 3.x can use: 2,6,10,15,20,21,22,23
Arduino's 8 bit: any
DUE: check arduino site
If you do not use reset, tie it to +3V3
*/

uint8_t errorCode = 0;

Grafx tft = Grafx(__CS1, __DC);

 int player_x = 160;
 int player_y = 110;
 int player_direction = 2;

 int x=-0,y=0;

 //////////Paul_Atreades
//////////paul front

const byte paul_frontblack[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x40,0x02,0x30,0x0c,0x38,0x1c,0x4c,0x32,0x4f,0xf2,0x39,0x9c,0x16,0x68,0x11,0x88,0x08,0x10,0x0e,0x70};

const byte paul_frontblue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x01,0x80,0x06,0x60,0x06,0x60,0x00,0x00};

const byte paul_frontbrown[] PROGMEM = {16,16,
0x0e,0x70,0x1b,0xd8,0x16,0x68,0x19,0x98,0x20,0x04,0x16,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontgreen[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontgrey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x08,0x10,0x00,0x00,0x00,0x00};

const byte paul_frontpink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x0f,0xf0,0x29,0x94,0x3d,0xbc,0x0d,0xb0,0x07,0xe0,0x33,0xcc,0x30,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontred[] PROGMEM = {16,16,
0x01,0x80,0x04,0x20,0x09,0x90,0x20,0x04,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0,0x00,0x00,0x00,0x00};

////////paul_front_walk_1

const byte paul_frontw1black[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x40,0x02,0x30,0x0e,0x38,0x1a,0x24,0x3c,0x27,0x98,0x19,0x68,0x0e,0x88,0x0e,0x10,0x00,0x10,0x00,0x70};

const byte paul_frontw1blue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x80,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00};

const byte paul_frontw1brown[] PROGMEM = {16,16,
0x0e,0x70,0x1b,0xd8,0x16,0x68,0x19,0x98,0x20,0x04,0x16,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw1green[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw1grey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw1pink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x0f,0xf0,0x29,0x94,0x3d,0xbc,0x0d,0xb0,0x07,0xe4,0x1b,0xc0,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw1red[] PROGMEM = {16,16,
0x01,0x80,0x04,0x20,0x09,0x90,0x20,0x04,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

////////paul_front_walk_2

const byte paul_frontw2black[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x40,0x02,0x70,0x0c,0x58,0x1c,0x3c,0x24,0x19,0xe4,0x16,0x98,0x11,0x70,0x08,0x70,0x08,0x00,0x0e,0x00};

const byte paul_frontw2blue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x02,0x40,0x00,0x00,0x00,0x00,0x06,0x00,0x01,0x60,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00};

const byte paul_frontw2brown[] PROGMEM = {16,16,
0x0e,0x70,0x1b,0xd8,0x16,0x68,0x19,0x98,0x20,0x04,0x16,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw2green[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw2grey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw2pink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x0f,0xf0,0x29,0x94,0x3d,0xbc,0x0d,0xb0,0x27,0xe0,0x03,0xd8,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_frontw2red[] PROGMEM = {16,16,
0x01,0x80,0x04,0x20,0x09,0x90,0x20,0x04,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

////////paul left

 const byte paul_leftblack[] PROGMEM = {16,16,
0x00,0x00,0x00,0x0,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x10,0x00,0x10,0x00,0x08,0x60,0x07,0xe0,0x00,0x20,0x03,0x20,0x04,0xe0,0x04,0x20,0x01,0xc0,0x03,0xc0};

const byte paul_leftblue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00};

const byte paul_leftbrown[] PROGMEM = {16,16,
0x0e,0xd8,0x0d,0xa8,0x1b,0x74,0x3e,0xec,0x01,0xd8,0x00,0xb4,0x00,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_leftgreen[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_leftgrey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0xc0,0x00,0x00,0x00,0x00};

const byte paul_leftpink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x0b,0x00,0x0b,0x60,0x0f,0xe0,0x07,0x80,0x00,0x00,0x00,0xc0,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_leftred[] PROGMEM = {16,16,
0x01,0x20,0x12,0x54,0x24,0x88,0x01,0x10,0x00,0x24,0x00,0x48,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

///////paul_left_walk

const byte paul_leftwblack[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x14,0x00,0x10,0x00,0x10,0x00,0x08,0x60,0x04,0xe0,0x1f,0x98,0x24,0x94,0x13,0xe4,0x12,0x44,0x02,0x24,0x0e,0x18};

const byte paul_leftwblue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x08,0x08,0x18,0x0c,0x38,0x0c,0x18,0x00,0x00};

const byte paul_leftwbrown[] PROGMEM = {16,16,
0x0e,0xe8,0x0d,0xd8,0x1b,0xb4,0x3f,0x6c,0x01,0xd8,0x00,0xb4,0x00,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_leftwgreen[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_leftwgrey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_leftwpink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x0b,0x00,0x0b,0x60,0x0f,0xe0,0x07,0x80,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_leftwred[] PROGMEM = {16,16,
0x01,0x10,0x12,0x24,0x24,0x48,0x00,0x90,0x00,0x24,0x00,0x48,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

////////paul_rear

 const byte paul_rearblack[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x40,0x02,0x30,0x0c,0x38,0x1c,0x49,0x92,0x5e,0x7a,0x39,0x9c,0x16,0x68,0x11,0x80,0x08,0x10,0x0e,0x70};

const byte paul_rearblue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x01,0x80,0x06,0x60,0x01,0x80,0x06,0x60,0x06,0x60,0x00,0x00};

const byte paul_rearbrown[] PROGMEM = {16,16,
0x0d,0xb0,0x0b,0xd0,0x1d,0xb8,0x1a,0x58,0x37,0xec,0x0d,0xb0,0x0b,0xd0,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_reargrey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x08,0x10,0x00,0x00,0x00,0x00};

const byte paul_rearpink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x04,0x30,0x0c,0x0c,0x30,0x07,0xe0,0x30,0x0c,0x20,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rearred[] PROGMEM = {16,16,
0x02,0x40,0x14,0x28,0x02,0x40,0x25,0xa4,0x08,0x10,0x12,0x48,0x04,0x20,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

///////paul_rear_walk1

 const byte paul_rearw1black[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x40,0x02,0x30,0x0e,0x3c,0x1a,0x49,0x9c,0x4e,0x78,0x33,0xe8,0x0e,0x88,0x0e,0x10,0x00,0x10,0x00,0x70};

const byte paul_rearw1blue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x01,0x80,0x0c,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00};

const byte paul_rearw1brown[] PROGMEM = {16,16,
0x0d,0xb0,0x0b,0xd0,0x1d,0xb8,0x1a,0x58,0x37,0xec,0x0d,0xb0,0x0b,0xd0,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rearw1grey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rearw1pink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x04,0x30,0x0c,0x0c,0x30,0x03,0xe4,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rearw1red[] PROGMEM = {16,16,
0x02,0x40,0x14,0x28,0x02,0x40,0x25,0xa4,0x08,0x10,0x12,0x48,0x04,0x20,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

///////paul_rear_walk2

const byte paul_rearw2black[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x02,0x40,0x02,0x70,0x0c,0x58,0x1c,0x39,0x92,0x1e,0x72,0x17,0x4c,0x11,0x70,0x08,0x70,0x08,0x00,0x0e,0x00};

const byte paul_rearw2blue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x01,0x80,0x00,0x30,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00};

const byte paul_rearw2brown[] PROGMEM = {16,16,
0x0d,0xb0,0x0b,0xd0,0x1d,0xb8,0x1a,0x58,0x37,0xec,0x0d,0xb0,0x0b,0xd0,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rearw2grey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rearw2pink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x04,0x30,0x0c,0x0c,0x30,0x27,0xc,0x00,0x0c,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rearw2red[] PROGMEM = {16,16,
0x02,0x40,0x14,0x28,0x02,0x40,0x25,0xa4,0x08,0x10,0x12,0x48,0x04,0x20,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

////////paul_right

 const byte paul_rightblack[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x00,0x08,0x00,0x08,0x06,0x10,0x07,0xe0,0x04,0x00,0x04,0xc0,0x07,0x20,0x04,0x20,0x03,0x80,0x03,0xc0};

const byte paul_rightblue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00};

const byte paul_rightbrown[] PROGMEM = {16,16,
0x1b,0x70,0x15,0xb0,0x2e,0xd8,0x37,0x7c,0x1b,0x80,0x2d,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rightgrey[] PROGMEM = {16,16,
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,0x80,0x03,0x80,0x00,0x00,0x00,0x00};

const byte paul_rightpink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xd0,0x06,0xd0,0x07,0xf0,0x01,0xe0,0x00,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rightred[] PROGMEM = {16,16,
0x04,0x80,0x2a,0x48,0x11,0x24,0x08,0x80,0x24,0x00,0x12,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

////////paul_right_walk

 const byte paul_rightwblack[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x00,0x08,0x00,0x08,0x06,0x10,0x07,0x20,0x19,0xf8,0x29,0x24,0x27,0xc8,0x22,0x48,0x24,0x40,0x18,0x70};

const byte paul_rightwblue[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x10,0x18,0x18,0x10,0x1c,0x30,0x18,0x30,0x00,0x00};

const byte paul_rightwbrown[] PROGMEM = {16,16,
0x17,0x70,0x1b,0xb0,0x2d,0xd8,0x36,0xfc,0x1b,0x80,0x2d,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rightwgrey[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rightwpink[] PROGMEM = {16,16,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xd0,0x06,0xd0,0x07,0xf0,0x01,0xe0,0x00,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const byte paul_rightwred[] PROGMEM = {16,16,
0x08,0x80,0x24,0x48,0x12,0x24,0x09,0x00,0x24,0x00,0x12,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const byte rock_black[] PROGMEM = {16,16,
B00010101,B10110100,B00001101,B10001110,B00001101,B10001101,B00001101,B10000101,B00001001,B10000101,B00001001,B10000001,B00001001,B10000110,B00001011,B00000010,B00001001,B10000001,B00011001,B10000001,B00111011,B10000011,B00100011,B11000010,B01000001,B10000010,B01000001,B10000010,B00000001,B11000111,B10000001,B10100110};

const byte rock_beige[] PROGMEM = {16,16,
B00001000,B00001000,B00000010,B00000001,B00000010,B00000000,B10000010,B00000000,B10000100,B00000000,B00000100,B00000000,B00000100,B00011001,B00000100,B00100001,B00000100,B00100000,B00000100,B00010000,B10000100,B00100000,B10011100,B00000001,B00100000,B01000001,B00100000,B01000001,B01000000,B00000000,B01010010,B0011001};

const byte rock_brown[] PROGMEM = {16,16,
B11100010,B01000011,B11110000,B01110000,B11110000,B01110010,B01110000,B01111010,B01110010,B01111010,B11110010,B01111110,B11110010,B01100000,B11110010,B01011100,B11110010,B01011110,B11100010,B01011110,B01000000,B01011100,B01000000,B00111100,B10011110,B00111100,B10011110,B00111100,B10111110,B00111000,B00101100,B01000000};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const byte sand_brown[] PROGMEM = {16,16,
B00010001,B00010001,B00000000,B00000000,B10001000,B10001000,B00000000,B00000000,B00010001,B00010001,B00000000,B00000000,B10001000,B10001000,B00000000,B00000000,B00010001,B00010001,B00000000,B00000000,B10001000,B10001000,B00000000,B00000000,B00010001,B00010001,B00000000,B00000000,B10001000,B10001000,B00000000,B00000000};

const byte sand_beige[] PROGMEM = {16,16,
B11101110,B11101110,B11111111,B11111111,B01110111,B01110111,B11111111,B11111111,B11101110,B11101110,B11111111,B11111111,B01110111,B01110111,B11111111,B11111111,B11101110,B11101110,B11111111,B11111111,B01110111,B01110111,B11111111,B11111111,B11101110,B11101110,B11111111,B11111111,B01110111,B01110111,B11111111,B11111111};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const byte blank_tile1[] PROGMEM = {16,16,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};

const byte blank_tile2[] PROGMEM = {16,16,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};

const byte blank_tile3[] PROGMEM = {16,16,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};

const byte *spritesheet1[] = {blank_tile1,rock_black,};

const byte *spritesheet2[] = {blank_tile2, rock_brown, sand_brown,};

const byte *spritesheet3[] = {blank_tile3, rock_beige, sand_beige,};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




///black
const byte tilemap1[] PROGMEM = {20,15,
16,16,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,
1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,
1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,
0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,
0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,
1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};

///brown
const byte tilemap2[] PROGMEM = {20,15,
16,16,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,
1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
1,1,1,1,1,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,};

///beige

const byte tilemap3[] PROGMEM = {20,15,
16,16,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,
1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
2,2,2,2,1,1,1,1,2,2,2,2,2,2,1,1,1,1,2,2,
1,1,1,1,1,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,};

//////dpad + select buttons
const int buttonUp = 33; //up button
Bounce ButtonUp = Bounce(buttonUp, 10);  // 10 ms debounce
const int buttonDown = 38; //down_button
Bounce ButtonDown = Bounce(buttonDown, 10);  // 10 ms debounce
const int buttonLeft = 35; //left button
Bounce ButtonLeft = Bounce(buttonLeft, 10);  // 10 ms debounce
const int buttonRight = 17; //right button
Bounce ButtonRight = Bounce(buttonRight, 10);  // 10 ms debounce
const int buttonS = 21; //select button
Bounce ButtonS = Bounce(buttonS, 10);  // 10 ms debounce

//////action + start buttons
const int buttonX = 32; // X button up
Bounce ButtonX = Bounce(buttonX, 10);  // 10 ms debounce
const int buttonY = 26; // Y button left
Bounce ButtonY = Bounce(buttonY, 10);  // 10 ms debounce
const int buttonA = 21; // A button right
Bounce ButtonA = Bounce(buttonA, 10);  // 10 ms debounce
const int buttonB = 28; // B buttun down
Bounce ButtonB = Bounce(buttonB, 10);  // 10 ms debounce
const int buttonT = 4; // Start button
Bounce ButtonT = Bounce(buttonT, 10);  // 10 ms debounce

void setup() {
   Serial.begin(38400);
   long unsigned debug_start = millis();
   while (!Serial && ((millis() - debug_start) <= 5000));
   Serial.println("serial ok, testing lib...");
  tft.begin();
  tft.setFrameRate(62);
  tft.persistence = false;
   pinMode(buttonUp, INPUT_PULLUP);
   pinMode(buttonDown, INPUT_PULLUP);
   pinMode(buttonLeft, INPUT_PULLUP);
   pinMode(buttonRight, INPUT_PULLUP);
   pinMode(buttonS, INPUT_PULLUP);
   pinMode(buttonX, INPUT_PULLUP);
   pinMode(buttonY, INPUT_PULLUP);
   pinMode(buttonA, INPUT_PULLUP);
   pinMode(buttonB, INPUT_PULLUP);
   pinMode(buttonT, INPUT_PULLUP);
   
//Serial.print("Initializing SD card...");
//  if (!SD.begin(SD_CS)) {
//    Serial.println("failed!");
//  }

//  Serial.println("OK!")

//the following it's mainly for Teensy
  //it will help you to understand if you have choosed the
  //wrong combination of pins!
  errorCode = tft.getErrorCode();
  if (errorCode != 0) {
     Serial.print("Init error! ");
     if (bitRead(errorCode, 0)) Serial.print("MOSI or SCLK pin mismach!\n");
     if (bitRead(errorCode, 1)) Serial.print("CS or DC pin mismach!\n");
  }
  else {
     Serial.println("Inited");
  }
}

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

void loop(void) {
//updates the GameRIot (the display, the sound, the buttons, everyyhing)
  //returns true when it's time to render a new frame (20 times/second)
   if(tft.updateAll()){

   if (ButtonUp.update());
   if (ButtonDown.update());
   if (ButtonLeft.update());
   if (ButtonRight.update());

   ButtonUp.rebounce(10);
   ButtonDown.rebounce(10);
   ButtonLeft.rebounce(10);
   ButtonRight.rebounce(10);
   
    if (ButtonUp.fallingEdge()){
       tft.drawBitmap1(player_x, player_y,paul_rearblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_rearblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_rearbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_reargrey,16,16,GREY);
           tft.drawBitmap1(player_x, player_y,paul_rearpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_rearred,16,16,RED);
   

           player_direction = 1;
             player_y = player_y - 1;}


       if (ButtonDown.fallingEdge()){
        tft.drawBitmap1(player_x, player_y,paul_frontblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_frontblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_frontbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_frontgrey,16,16,GREY);
          tft.drawBitmap1(player_x, player_y,paul_frontgreen,16,16,GREEN);
           tft.drawBitmap1(player_x, player_y,paul_frontpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_frontred,16,16,RED);
       

           player_direction = 2;
            player_y = player_y + 1;}

       if (ButtonLeft.fallingEdge()){
        tft.drawBitmap1(player_x, player_y,paul_leftblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_leftblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_leftbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_leftgreen,16,16,GREEN);
          tft.drawBitmap1(player_x, player_y,paul_leftgrey,16,16,GREY);
           tft.drawBitmap1(player_x, player_y,paul_leftpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_leftred,16,16,RED);
       

           player_direction = 3;
             player_x = player_x - 1;}


       if (ButtonRight.fallingEdge()){
        tft.drawBitmap1(player_x, player_y,paul_rightblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_rightblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_rightbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_rightbrown,16,16,GREY);
           tft.drawBitmap1(player_x, player_y,paul_rightpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_rightred,16,16,RED);
       

            player_direction = 4;
            player_x = player_x + 1;}

         
       /////////////////PLAYER DIRECTION/////////////////

        if (player_direction == 1){
          tft.drawBitmap1(player_x, player_y,paul_rearblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_rearblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_rearbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_reargrey,16,16,GREY);
           tft.drawBitmap1(player_x, player_y,paul_rearpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_rearred,16,16,RED);

       }

      else if (player_direction == 2){
         tft.drawBitmap1(player_x, player_y,paul_frontblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_frontblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_frontbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_frontgrey,16,16,GREY);
          tft.drawBitmap1(player_x, player_y,paul_frontgreen,16,16,GREEN);
           tft.drawBitmap1(player_x, player_y,paul_frontpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_frontred,16,16,RED);

              }


       else if (player_direction == 3){
         tft.drawBitmap1(player_x, player_y,paul_leftblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_leftblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_leftbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_leftgreen,16,16,GREEN);
          tft.drawBitmap1(player_x, player_y,paul_leftgrey,16,16,GREY);
           tft.drawBitmap1(player_x, player_y,paul_leftpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_leftred,16,16,RED);

            }


        else if (player_direction == 4){
          tft.drawBitmap1(player_x, player_y,paul_rightblack,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_rightblue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_rightbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_rightbrown,16,16,GREY);
          tft.drawBitmap1(player_x, player_y,paul_rightpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_rightred,16,16,RED);

               }
             
          }
     }

 


Still playing with controls. Ok if you use the sketch above the player moves very easily. But when you add the tilemap he moves very slow. I had to make the the +1 in the movement 5 and it's still a lil annoyingly slow.

You can tweak the milliseconds on the buttons to save power, only updating some fast.

I haven't fixed the tilemap yet I just wanted to see how the player reacts with one behind it.


https://youtu.be/bRqo2YXLKzo

Now on github........

https://github.com/Duhjoker/GameRIot_ESP

https://github.com/Duhjoker/GameRIot-master_gaming
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Gamebuino Advanced prototype has been built

Postby Duhjoker » Thu Jul 27, 2017 4:28 am

Ok so I updated the player/camera controls and now I have them dialed it just right. Take a look at this......

Code: Select all
 int player_x = 160;     //player position on screen x
 int player_y = 176;     //player position on screen y
 int player_direction = 2;
 int x=-0,y=0;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Camera offset
int cameraX = -840;  /////starting position X 0f camera on tilemap
int cameraY = -1504;  /////starting position Y of camera on tilemap

// Camera speed in pixels per update
int cameraXSpeed = 3;
int cameraYSpeed = 3;

// Camera offset boundaries
const int cameraXMin = -1376;   /////// -320 0f total pixels left
const int cameraXMax = 0;
const int cameraYMin = -1440;   /////// -256 0f total pixels down
const int cameraYMax = 0;

// Player offset boundaries
const int playerXMin = 80;
const int playerXMax = 240;
const int playerYMin = 80;
const int playerYMax = 160;



ok so the first set is for displaying the character on screen, that should be self explanatory. Next we have camera placement on screen where you want to start. Next is camera speed. Displaying bitmaps on top of bitmaps and then commanding them to move with each other causes friction which makes the movements like ssssssllllllloooooooooooooooowwwwwwww dial up. so now we can speed up the the rate at which new pixels show up on screen. The buffer helps but this Makes things a lot smoother.

the camera offset boundaries will need to change to the specifics of your tilemap. For the ili9341 tft subtract the commented numbers by the total pixel width 0f the map. The player offset boundaries should not change. Are dialed in just right for the screen,

ok now heres the magic

Code: Select all
///////////////////////////////////////////////////////////////////////////////
////////////////////////////////camera controls////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Clamp cameraX
if(cameraX < cameraXMin)
{
  cameraX = cameraXMin;
}
else if(cameraX > cameraXMax)
{
   cameraX = cameraXMax;
}

// Clamp cameraY
if(cameraY < cameraYMin)
{
  cameraY = cameraYMin;
}
else if(cameraY > cameraYMax)
{
   cameraY = cameraYMax; 
}

// Check if player is beyond X boundary
if(player_x < playerXMin)
{
  cameraX += cameraXSpeed;
  if(cameraX > cameraXMin && cameraX < cameraXMax)
  {
    player_x = playerXMin;
  }
}
else if(player_x > playerXMax)
{
  cameraX -= cameraXSpeed;
  if(cameraX > cameraXMin && cameraX < cameraXMax)
  {
    player_x = playerXMax;
  }
}

// Check if player is beyond Y boundary
if(player_y < playerYMin)
{
  cameraY += cameraYSpeed;
  if(cameraY > cameraYMin && cameraY < cameraYMax)
  {
    player_y = playerYMin;
  }
}
else if(player_y > playerYMax)
{
  cameraY -= cameraYSpeed;
  if(cameraY > cameraYMin && cameraY < cameraYMax)
  {
    player_y = playerYMax;
  }
}


by clamping the camera like so all we have to do is change the pixel coordinates and making dialing in your world map much easier.
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Previous

Return to Hardware Gallery

Who is online

Users browsing this forum: No registered users and 2 guests

cron