Using frame buffering to solidify tft displayed objects

Status
Not open for further replies.
The guy in the other forum found something.
Code:
byte numcolision = 3;     //count of solid objects indacat how many tiles drawed on the screen - ADD by Summoner123
numcolision needs to be a int type now as a byte type can only count to 255. Putting the 3 there makes no difference as it is a variable and will be changed. Don't change the line 735 comment line.

The place to print things out would be in your function checkcolision, but why don't you make the change of numcolision from a byte to an int and see what happens then.
 
Freaking awesome!!!!!! I wont do the happy happy joy joy dance this time, lol. but making the changes from earlier and changing byte to int seems to have done the trick!!!!!!!!!!! Another function down, two to go then I can get out of your hair and make some games.

https://youtu.be/EN1Iql2mEuk

the first of the last two is a functions is a function called popup() which allows a roundrect() to appear on screen and show messages. The function of course was written for the nokia 5110 lcd. Ive tried to work on it but it just wont show up. here is the original......

Code:
void Gamebuino::popup(const __FlashStringHelper* text, uint8_t duration){
#if (ENABLE_GUI > 0)
	popupText = text;
	popupTimeLeft = duration+12;
#endif
}

void Gamebuino::updatePopup(){
#if (ENABLE_GUI > 0)
	if (popupTimeLeft){
		uint8_t yOffset = 0;
		if(popupTimeLeft<12){
			yOffset = 12-popupTimeLeft;
		}
		display.fontSize = 1;
		display.setColor(WHITE);
		display.fillRoundRect(0,LCDHEIGHT-display.fontHeight+yOffset-3,84,display.fontHeight+3,3);
		display.setColor(BLACK);
		display.drawRoundRect(0,LCDHEIGHT-display.fontHeight+yOffset-3,84,display.fontHeight+3,3);
		display.cursorX = 4;
		display.cursorY = LCDHEIGHT-display.fontHeight+yOffset-1;
		display.print(popupText);
		popupTimeLeft--;
	}
#endif
}

and here is my version....
Code:
  void GrafxT3::popup(const __FlashStringHelper* text, uint8_t duration){
	popupText = text;
	popupTimeLeft = duration+12;
}

void GrafxT3::updatePopup(){
	if (popupTimeLeft){
		uint8_t yOffset = 0;
		if(popupTimeLeft<12){
			yOffset = 12-popupTimeLeft;
		}
		setTextSize(1);
//		setColor(WHITE);
		fillRoundRect(0,GrafxT3_TFTHEIGHT-textsize+yOffset-3,84,textsize+3,3,WHITE);
//		setColor(BLACK);
		drawRoundRect(0,GrafxT3_TFTHEIGHT-textsize+yOffset-3,84,textsize+3,3,BLACK);
		setCursor( 4, GrafxT3_TFTHEIGHT-textsize+yOffset-1);
		print(popupText);
		popupTimeLeft--;
	}
}

I had it compiling though. but can you see why its not working?



and thank you for the help with collision!!!!!!
 
Last edited:
First suspect is the uint8_t type for yOffset. But it doesn't look like it will hold a large number but I would make it an int type anyway. 2nd suspect is the 84 hardcoded in the calls to drawRoundRect since 84 is the width of the nokia display. But I wouldn't worry too much about that as you have a much larger display and may not want your rectangle to cover the whole width of the display. You can adjust that once you get something on the screen.

To make it show up I think you need two things added to your loop(). You need to call updatePopup at the end of all your drawing and before you call updateScreen. That will put the popup on top off everything else drawn to the screen. For testing I suggest you add to one of your button direction if statement blocks a call to popup with the text to display and the duration. For example when you press the left button, call popup. The duration appears to be in frames, maybe 200 would be a reasonable value to try first.
 
Im trying to do a room switch using the collision functions, the switch code is pretty easy but I keep getting iso forbids errors when I try to compile it. But left me explain how it works...

first we add...
Code:
int room = 1;

to the top of the sketch. Next we take the two tilemaps and turn them into if statements like so
Code:
     if(room == 1){
  tft.drawTilemap(cameraX, cameraY, dune_demo, spritesheet, palette);}
     if(room == 2){
  tft.drawTilemap(cameraX = 0, cameraY = 0, room1, spritesheet, palette);}

now we add a bit of code to a tile we listed in the collision to act as a trigger to switch maps.
Code:
else if(tft.solid[i].spritecol == cave) && room == 1) {room = 2; player_x = 32; player_y = 204;} //return true;

Now if I touch a cave it should switch rooms from 1=dune_demo to 2=room1. But it will not compile the sketch for these reasons....
Code:
Arduino: 1.8.2 (Windows 7), TD: 1.36, Board: "Teensy 3.6, Serial, 180 MHz, Faster, US English"

Dune_RPG: In function 'void setup()':
Dune_RPG:122: warning: unused variable 'start_time' 
      uint32_t start_time = millis(); 

               ^

Dune_RPG: In function 'void loop()':
Dune_RPG:201: warning: large integer implicitly truncated to unsigned type 
                                     palette[6] = PINK;

                                                ^

Dune_RPG: In function 'bool checkcolision()':
Dune_RPG:323: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
       else if(tft.solid[i].spritecol == cave) && room == 1) {room = 2; player_x = 32; player_y = 204;} //return true;

                                                          ^

Dune_RPG:323: error: expected ';' before ')' token
       else if(tft.solid[i].spritecol == cave) && room == 1) {room = 2; player_x = 32; player_y = 204;} //return true;

                                                           ^

Dune_RPG:323: warning: statement has no effect 
       else if(tft.solid[i].spritecol == cave) && room == 1) {room = 2; player_x = 32; player_y = 204;} //return true;

                                                       ^

Dune_RPG:323: error: label 'room' used but not defined
       else if(tft.solid[i].spritecol == cave) && room == 1) {room = 2; player_x = 32; player_y = 204;} //return true;

                                                  ^

ISO C++ forbids comparison between pointer and integer [-fpermissive]

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

here is the example sketch that ive been working from.....
Code:
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;



const byte tilemap1[] PROGMEM = {17,11,
8,8,

 2, 2, 2, 2, 2, 2, 2, 2,26,26,26,26,26,26,26,26, 2,
 2, 2, 2, 2, 2, 2, 2,19,26,26,26,26,26,26,26,26,20,
 2, 2, 2, 2, 2, 2, 2,19,25,26,26,25,25,25,25,25,20,
 2, 2, 2, 2, 2, 2,18, 4, 8,25,26,56,57,58,59,60,20,
 2, 2, 2, 2, 2, 4, 8, 8, 8, 8,25,51,52,53,54,55,20,
 2, 2, 2, 2, 4, 8, 8, 8, 8, 8, 8,46,47,48,49,50,20,  /////////112x64 pix res
18,18,18, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3,
28, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,29,
21,21, 6, 8, 8, 8,22,23,24, 8, 8, 8, 8, 8, 5,21,21,
 2, 2,19, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,20, 2, 2,
 2, 2, 2,21,21,21,21,21,21,21,21,21,21,21, 2, 2, 2};

const byte tilemap2[] PROGMEM = {17,11,
8,8,
 2, 2, 2, 2, 2, 2, 2,19,30,30, 3,18,18,18,18,18, 2,
 2, 2, 2, 2, 2, 2, 2,19, 8, 8,27,27,27,27,27,27,20,
 2, 2, 2, 2, 2, 2, 2,19, 8, 8,26,26,26,26,26,26,20,
 2, 2, 2, 2, 2, 2,18, 4, 8, 8,25,26,26,26,26,26,20,
 2, 2, 2, 2, 2, 4, 8, 8, 8, 8, 8,26,26,26,26,26,20,
 2, 2, 2, 2, 4, 8, 8, 8, 8, 8, 8,26,26,26,26,26,20,  /////////112x64 pix res
18,18,18, 4, 8, 8, 8,27, 8, 8, 8, 8,25,25,25,25, 3,
28, 8, 8, 8, 8, 8,27,26,27, 8, 8, 8, 8, 8, 8, 8,29,
21,21, 6, 8, 8,27,26,26,26,27, 8, 8, 8, 8, 5,21,21,
 2, 2,19, 8, 8,25,25,25,25,25, 8, 8, 8, 8,20, 2, 2,
 2, 2, 2,21,21,21,21,21,21,21,21,21,21,21, 2, 2, 2};

const byte tilemap3[] PROGMEM = {17,11,
8,8,
 2, 2, 2, 2, 2, 2, 2, 2,18,18,18,18,18,18,18,18, 2,
 2, 2, 2, 2, 2, 2, 2,19, 8, 8, 8, 8, 8, 8, 8, 8,20,
 2, 2, 2, 2, 2, 2, 2,19, 8, 8, 8, 8, 8, 8, 8, 8,20,
 2,18,18,18,18,18,18, 4, 8, 8, 8, 8, 5,21,21,21, 2,
19, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 2, 2, 2, 2, 2,
19, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 2, 2, 2, 2, 2, 2,  /////////112x64 pix res
19, 8, 8, 5,21,21,21, 6, 8, 8,20, 2, 2, 2, 2, 2, 2,
19, 8, 8,20, 2, 2, 2,19, 8, 8,20, 2, 2, 2, 2, 2, 2,
19,34, 8,20, 2, 2, 2,19, 8, 8,20, 2, 2, 2, 2, 2, 2,
 2,21,21, 2, 2, 2, 2,19, 8, 8,20, 2, 2, 2, 2, 2, 2,
 2, 2, 2, 2, 2, 2, 2,19,28,28,20, 2, 2, 2, 2, 2, 2};

const byte tilemap4[] PROGMEM = {17,11,
8,8,
 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, 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,18,18,18,18,18, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19, 8, 8, 8,36, 8,20, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19, 8, 8, 8, 8, 8,20, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  /////////112x64 pix res
19, 8, 8, 5,21,21, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19, 8, 8,20, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19,35, 8,20, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
 2,21,21, 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, 2, 2, 2, 2, 2};

 const byte tilemap5[] PROGMEM = {12,11,
8,8,
45,45,45,45,45,45,45,45,45,45,45,45,
45,45,37,37,37,37,37,37,37,45,45,45,
45,41,61,61,61,61,61,62,61,40,45,45,
45,41, 8, 8, 8, 8, 8,63, 8,40,45,45,
45,41, 8, 8, 8, 8, 8,64, 8,40,45,45,
45,41, 8, 8, 8, 8, 8, 8, 8,40,45,45,  /////////112x64 pix res
45,41, 8, 8, 8, 8, 8, 8, 8,40,45,45,
45,41, 8, 8, 8, 8, 8, 8, 8,40,45,45,
45,41, 8, 8, 8, 8, 8, 8, 8,40,45,45,
45,45,42,42,44, 8,43,42,42,45,45,45,
45,45,45,45,41,28,40,45,45,45,45,45,};

const byte bush[] PROGMEM = {B00101100,B01010010,B10001001,B01000010,B10010001,B01001010,B00100100,B01111110,};
const byte port_noir[] PROGMEM = {B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,};
const byte rock_terrain_master[] PROGMEM = {B00000010,B00010000,B01000000,B00000010,B00010000,B00001000,B01000001,B00000100,};
const byte rock_valley_ne[] PROGMEM = {B10100000,B11001001,B01110000,B00001100,B00000101,B00000100,B00000110,B00000011,};
const byte rock_valley_nw[] PROGMEM = {B00000101,B10010011,B00001110,B00110000,B10100000,B00100000,B01100000,B11000000,};
const byte rock_valley_se[] PROGMEM = {B00000011,B00000110,B00000100,B00000101,B00001100,B01110000,B11001001,B10100000,};
const byte rock_valley_sw[] PROGMEM = {B11000000,B01100000,B00100000,B10100000,B00110000,B00001110,B10010011,B00000101,};
const byte turtle_rock[] PROGMEM = {B01101100,B10110010,B11010001,B01010101,B01010010,B10011001,B10000001,B11111110,};
const byte void_tile[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte water_left_bottom[] PROGMEM = {B10001111,B10000000,B11110000,B10000000,B10001111,B10000000,B11110000,B11111111,};
const byte water_left_middle[] PROGMEM = {B10001111,B10000000,B11110000,B10000000,B10001111,B10000000,B11110000,B10000000,};
const byte water_left_top[] PROGMEM = {B11111111,B10000000,B11110000,B10001111,B10000000,B10000000,B11110000,B10000000,};
const byte water_right_bottom[] PROGMEM = {B1110001,B00000001,B0000111,B00000001,B11110001,B00000001,B00001111,B11111111,};
const byte water_right_middle[] PROGMEM = {B11110001,B00000001,B00001111,B00000001,B11110001,B00000001,B00001111,B00000001,};
const byte water_right_top[] PROGMEM = {B11111111,B00000001,B00001111,B00000001,B11110001,B00000001,B00001111,B00000001,};
const byte water_middle_bottom[] PROGMEM = {B11110000,B00000000,B00001111,B00000000,B11110000,B00000000,B00001111,B11111111,};
const byte water_middle_middle[] PROGMEM = {B11110000,B00000000,B00001111,B00000000,B11110000,B00000000,B00001111,B00000000,};
const byte water_middle_top[] PROGMEM = {B11111111,B00000000,B11110000,B00000000,B00001111,B00000000,B11110000,B00000000,};
const byte rock_s[] PROGMEM = {B00010010,B00000000,B01001000,B00000100,B00100001,B10001100,B01110010,B10000001,};
const byte rock_e[] PROGMEM = {B00000101,B00100010,B00001010,B10000010,B00100100,B00010100,B10000010,B00001001,};
const byte rock_n[] PROGMEM = {B10000001,B01110010,B10001100,B00100001,B00000100,B01001000,B00000000,B00010010,};
const byte rock_w[] PROGMEM = {B10100000,B01000100,B01010000,B01000001,B00100100,B00101000,B01000001,B10010000,};
const byte bush_left[] PROGMEM = {B00111011,B01000100,B10100000,B10010100,B01000010,B10000000,B10001000,B01110111,};
const byte bush_middle[] PROGMEM = {B10111101,B01000010,B00001000,B10000100,B00010000,B00100001,B10001000,B01110111,};
const byte bush_right[] PROGMEM = {B11011100,B00100010,B00000101,B00101001,B01000010,B00000001,B00010001,B11101110,};
const byte tree_base[] PROGMEM = {B01010100,B01000100,B10100010,B10001010,B10000010,B01101100,B00101000,B00101000,};
const byte tree_repeat[] PROGMEM = {B01010100,B01000100,B10000010,B10010010,B10101010,B01101100,B00101000,B01000100,};
const byte tree_top[] PROGMEM = {B00000000,B00000000,B00000000,B00010000,B00101000,B00101000,B00101000,B01000100,};
const byte exit_1[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte exit_2[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte exit_3[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte exit_4[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte exit_5[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte exit_6[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte cave_ladder[] PROGMEM = {B11000011,B11011011,B11000011,B11011011,B11000011,B11011011,B11000011,B11011011,};
const byte ladder[] PROGMEM = {B00111100,B00100100,B00111100,B00100100,B00111100,B00100100,B00111100,B00100100,};
const byte tombstone[] PROGMEM = {B00111100,B01000010,B10000001,B10111001,B10000001,B10101101,B10000001,B11111111,};
const byte WallB[] PROGMEM = {B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B00000000,B11111111,};
const byte WallBL[] PROGMEM = {B10111111,B10111111,B10111111,B10111111,B10111111,B10111111,B10000000,B11111111,};
const byte WallBR[] PROGMEM = {B11111101,B11111101,B11111101,B11111101,B11111101,B11111101,B00000001,B11111111,};
const byte WallL[] PROGMEM = {B10111111,B10111111,B10111111,B10111111,B10111111,B10111111,B10111111,B10111111,};
const byte WallR[] PROGMEM = {B11111101,B11111101,B11111101,B11111101,B11111101,B11111101,B11111101,B11111101,};
const byte WallT[] PROGMEM = {B11111111,B00000000,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,};
const byte WallTL[] PROGMEM = {B11111111,B10000000,B10111111,B10111111,B10111111,B10111111,B10111111,B10111111,};
const byte WallTR[] PROGMEM = {B11111111,B00000001,B11111101,B11111101,B11111101,B11111101,B11111101,B11111101,};
const byte blackwall[] PROGMEM = {B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,};
const byte houseB1[] PROGMEM = {B01010011,B01010010,B01010010,B01010001,B11110000,B10011111,B10010010,B11111111,};
const byte houseB2[] PROGMEM = {B11111000,B01001000,B01001000,B11110000,B00000000,B11111111,B01001000,B11111111,};
const byte houseB3[] PROGMEM = {B00111100,B01100110,B11000011,B10011001,B10000001,B10000101,B10000001,B11111111,};
const byte houseB4[] PROGMEM = {B00011111,B00010010,B00010010,B00001111,B00000000,B11111111,B00010010,B11111111,};
const byte houseB5[] PROGMEM = {B11001010,B01001010,B01001010,B10001010,B00001111,B11111001,B01001001,B11111111,};
const byte houseT1[] PROGMEM = {B11111111,B01010010,B01011111,B01010000,B01010000,B11110001,B10010010,B11110010,};
const byte houseT2[] PROGMEM = {B11111111,B01001001,B11111111,B00000000,B00000000,B11110000,B01001000,B01001000,};
const byte houseT3[] PROGMEM = {B11111111,B00100100,B11111111,B00000000,B01111110,B10100101,B11111111,B00000000,};
const byte houseT4[] PROGMEM = {B11111111,B10010010,B11111111,B00000000,B00000000,B00001111,B00010010,B00010010,};
const byte houseT5[] PROGMEM = {B11111111,B01001010,B11111010,B00001010,B00001010,B10001111,B01001001,B01001111,};
const byte roof1[] PROGMEM = {B00000000,B00011111,B00110010,B00101101,B01000000,B01010010,B11101101,B10000000,};
const byte roof2[] PROGMEM = {B00000000,B11111111,B01001001,B10110110,B00000000,B01001001,B10110110,B00000000,};
const byte roof3[] PROGMEM = {B00000000,B11111111,B00100100,B11011011,B00000000,B00100100,B11011011,B00000000,};
const byte roof4[] PROGMEM = {B00000111,B11111100,B10010111,B01101100,B00000100,B10010111,B01101101,B00000000,};
const byte roof5[] PROGMEM = {B10000000,B11111000,B11001100,B10110100,B10000010,B11001010,B10110111,B00000001,};
const byte wallpaper[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,};
const byte bedbottom[] PROGMEM = {B10111101,B11000011,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
const byte bedmid[] PROGMEM = {B11111111,B10000001,B10000001,B10000001,B10111101,B11000011,B10000001,B10000001,};
const byte bedtop[] PROGMEM = {B00000000,B00000000,B00000000,B00111100,B11000011,B10000001,B10111101,B10100101,};





const byte *spritesheet[] = {bush,    //0
port_noir,                            //1
rock_terrain_master,                  //2
rock_valley_ne,                       //3
rock_valley_nw,                       //4
rock_valley_se,                       //5
rock_valley_sw,                       //6
turtle_rock,                          //7
void_tile,                            //8
water_left_bottom,                    //9
water_left_middle,                    //10
water_left_top,                       //11
water_right_bottom,                   //12
water_right_middle,                   //13
water_right_top,                      //14
water_middle_bottom,                  //15
water_middle_middle,                  //16
water_middle_top,                     //17
rock_s,                               //18
rock_e,                               //19
rock_w,                               //20
rock_n,                               //21
bush_left,                            //22
bush_middle,                          //23
bush_right,                           //24
tree_base,                            //25
tree_repeat,                          //26
tree_top,                             //27
exit_1,                               //28
exit_2,                               //29
exit_3,                               //30
exit_4,                               //31
exit_5,                               //32
exit_6,                               //33
cave_ladder,                          //34
ladder,                               //35
tombstone,                            //36
WallB,                                //37
WallBL,                               //38
WallBR,                               //39
WallL,                                //40
WallR,                                //41
WallT,                                //42
WallTL,                               //43
WallTR,                               //44
blackwall,                            //45
houseB1,                              //46
houseB2,                              //47
houseB3,                              //48
houseB4,                              //49
houseB5,                              //50
houseT1,                              //51
houseT2,                              //52
houseT3,                              //53
houseT4,                              //54
houseT5,                              //55
roof1,                                //56
roof2,                                //57
roof3,                                //58
roof4,                                //59
roof5,                                //60
wallpaper,                            //61
bedtop,                               //62
bedmid,                               //63
bedbottom};                           //64

const byte backblack[] PROGMEM = {8,8,0x7E,0x42,0x42,0x3C,0x7E,0x3C,0x3C,0x24,};
const byte backgrey[] PROGMEM = {8,8,0x1,0x1,0x1,0xC1,0x81,0xC0,0x40,0x0,};
const byte frontblack[] PROGMEM = {8,8,0x7E,0x66,0x42,0x38,0x78,0x38,0x3C,0x24,};
const byte frontgrey[] PROGMEM = {8,8,0x80,0x80,0x80,0x87,0x87,0x7,0x2,0x0,};
const byte leftblack[] PROGMEM = {8,8,0x3E,0x32,0x22,0x1C,0x1C,0x1C,0x1C,0x14,};
const byte leftgrey[] PROGMEM = {8,8,0x0,0x0,0x0,0x60,0x60,0x60,0x40,0x0,};
const byte rightblack[] PROGMEM = {8,8,0x7C,0x4C,0x44,0x38,0x3C,0x38,0x38,0x28,};
const byte rightgrey[] PROGMEM = {8,8,0x2,0x2,0x2,0x2,0x2,0x0,0x0,0x0,};


  int player_x = 70;    //cant get these to center
  int player_y = 40;    //cant get these to center
  int player_direction = 0;
  int room = 1;
  int co_ords = 1;

int x,y; ///if 0 player spite will not move, -50,50 no tilemap

//////CAMERA//////
int camerax = -20 ;
int cameray = -20 ;
int animTransition;


void setup() {
  gb.begin();
  gb.titleScreen(F("test"));
  gb.setFrameRate(62);  ////////for sprite
  gb.display.persistence = false;
//  animTransition=-6;
}

/////////PLAYER_MOVEMENT\\\\\\\\\

void loop() {
  if(gb.update()){
    if (gb.buttons.repeat(BTN_RIGHT,1));{x--;}
    if (gb.buttons.repeat(BTN_LEFT,1));{x++;}
    if (gb.buttons.repeat(BTN_DOWN,1));{y--;}
    if (gb.buttons.repeat(BTN_UP,1));{y++;}


//      if(player_x > 64 ) {camerax-=2; player_x -=2;}    //Y Scrolling  right
//else  if(player_x < 10 ){camerax+=2; player_x +=2;}   //Y Scrolling  left
  
//        if(player_y > 28 ) {cameray-=2; player_y -=2;}    //Y Scrolling  Down
//else  if(player_y < 10 ){cameray+=2; player_y +=2;}   //Y Scrolling  Up

//      if(cameray > 0)cameray=0;   
//else  if(cameray < -24) cameray = -24;
//      if(camerax > 0)camerax=0;   
//else  if(camerax < -36) camerax = -36;

if(player_x > 59 && camerax <  0 && camerax  > -52){player_x = 59;camerax--;}
else  if(player_x < 15 && camerax <  0 && camerax  > -52){player_x = 15;camerax++;}
else  if(player_x > 59 && camerax <= 0 && camerax >= -52)camerax--;
else  if(player_x < 15 && camerax <= 0 && camerax >= -52)camerax++;   
  
  
      if(player_y > 28 && cameray < 0 && cameray >  -40){player_y = 28;cameray--;}
else  if(player_y < 15 && cameray < 0 && cameray >  -40){player_y = 15;cameray++;}
else  if(player_y > 28 && cameray <= 0 && cameray >= -40)cameray--;
else  if(player_y < 15 && cameray <= 0 && cameray >= -40)cameray++;  

      if(camerax > 0)camerax= 0;
else  if(camerax < -52) camerax = -52;
  
      if(cameray > 0)cameray= 0;   
else  if(cameray < -40) cameray = -40;

  if(room == 1){
    gb.display.drawTilemap(camerax,cameray,tilemap1,spritesheet);} // draw the tilemap
 //  gb.display.cursorY = 12; gb.display.println( player_x );gb.display.println( player_y );
  if(room == 2){
    gb.display.clear();
   gb.display.drawTilemap(camerax,cameray,tilemap2,spritesheet);} // draw the tilemap
 //   gb.display.cursorY = 12; gb.display.println( player_x );gb.display.println( player_y );
  if(room == 3){
    gb.display.clear();
   gb.display.drawTilemap(camerax,cameray,tilemap3,spritesheet);} // draw the tilemap
//    gb.display.cursorY = 12; gb.display.println( player_x );gb.display.println( player_y );
  if(room == 4){
    gb.display.clear();
   gb.display.drawTilemap(camerax,cameray,tilemap4,spritesheet);} // draw the tilemap
//    gb.display.cursorY = 12; gb.display.println( player_x );gb.display.println( player_y );
  if(room == 5){
    gb.display.clear();
   gb.display.drawTilemap(camerax,cameray,tilemap5,spritesheet);} // draw the tilemap
//    gb.display.cursorY = 12; gb.display.println( player_x );gb.display.println( player_y );



//if(gb.buttons.repeat(BTN_A,1)){
//    gb.display.setColor(BLACK);
//    gb.display.fillRect(0,0,84,48);
//    gb.display.setColor(WHITE);
//    gb.display.fillRect(animTransition,animTransition,84-(2*animTransition),48-(2*animTransition));
//    gb.display.setColor(BLACK);
//    {animTransition = animTransition + 6;}
//  }
//  if(gb.buttons.repeat(BTN_B,1)){
//    gb.display.setColor(BLACK);
//    gb.display.fillRect(0,0,84,48);
//    gb.display.setColor(WHITE);
//    gb.display.fillRect(animTransition,animTransition,84-(2*animTransition),48-(2*animTransition));
//    gb.display.setColor(BLACK);
//    {animTransition = animTransition - 6;}
//  }

 if(gb.buttons.repeat(BTN_UP,1)){
       gb.display.setColor(BLACK);{
    gb.display.drawBitmap(player_x,player_y,backblack);
       }
    gb.display.setColor(GRAY);{
    gb.display.drawBitmap(player_x,player_y,backgrey);
    }
      player_direction = 1;
      player_y = player_y - 1;
      if(checkcolision())player_y++;  // ADD by Summoner123 - If have colision on the new position regreat one Pixel
      }

      
    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,frontblack);
    }
     gb.display.setColor(GRAY);{
    gb.display.drawBitmap(player_x,player_y,frontgrey);
    } 
      player_direction = 2;
      player_y = player_y + 1;
      if(checkcolision())player_y--;  // ADD by Summoner123 - If have colision on the new position regreat one Pixel
      }
      
    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,rightblack);
    }
     gb.display.setColor(GRAY);{
    gb.display.drawBitmap(player_x,player_y,rightgrey);
    }
      player_direction = 3;
      player_x = player_x + 1;
      if(checkcolision())player_x--;  // ADD by Summoner123 - If have colision on the new position regreat one Pixel
      }
      
      
    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,leftblack);
    }
    gb.display.setColor(GRAY);{
    gb.display.drawBitmap(player_x,player_y,leftgrey);
    }
      player_direction = 4;
      player_x = player_x - 1;
      
      if(checkcolision())player_x++;  // ADD by Summoner123 - If have colision on the new position regreat one Pixel
      }
      
    if(player_x <= -2){
      player_x = -2;}
      
      ////////////PLAYER DIRECTION/////////////

 if (player_direction == 1){
        gb.display.setColor(BLACK);{
        gb.display.drawBitmap(player_x,player_y,backblack);
      }
        gb.display.setColor(GRAY);{
        gb.display.drawBitmap(player_x,player_y,backgrey);
        }
 }
      
      else if (player_direction == 2){
        gb.display.setColor(BLACK);{
        gb.display.drawBitmap(player_x,player_y,frontblack);
      }
        gb.display.setColor(GRAY);{
        gb.display.drawBitmap(player_x,player_y,frontgrey);
        }
      }
else if (player_direction == 3){
        gb.display.setColor(BLACK);{
        gb.display.drawBitmap(player_x,player_y,rightblack);
      }
        gb.display.setColor(GRAY);{
        gb.display.drawBitmap(player_x,player_y,rightgrey);
        }
}
      else if (player_direction == 4){
        gb.display.setColor(BLACK);{
        gb.display.drawBitmap(player_x,player_y,leftblack);
      }
        gb.display.setColor(GRAY);{
        gb.display.drawBitmap(player_x,player_y,leftgrey);
        }
      }
      else {  gb.display.setColor(BLACK);{
        gb.display.drawBitmap(player_x,player_y,frontblack);
      }
        gb.display.setColor(GRAY);{
        gb.display.drawBitmap(player_x,player_y,frontgrey);
        }
      }
} 
  

gb.display.setColor(BLACK);

if(gb.buttons.held(BTN_B,20)){
    co_ords = co_ords + 1;}

if(co_ords == 1){
  gb.display.cursorY = 12; gb.display.println( player_x );gb.display.println( player_y );}
else if(co_ords == 2){
  gb.display.cursorY = 12; gb.display.println( camerax );gb.display.println( cameray );}
else if(co_ords >= 3){
    co_ords = 0;}

}



     bool checkcolision() // Transformed it into a function
   {
    uint16_t i;
     for(i=0; i < gb.display.numcolision + 1; i++)
   {
    if(gb.collideRectRect(player_x,player_y,8,8,gb.display.solid[i].x,gb.display.solid[i].y,8,8))///changed player_x,y back to 8
    {
        //  if(gb.display.solid[i].spritecol == void_tile); //Do nothing because it's floor - This line not needed
          if(gb.display.solid[i].spritecol == bush) return true;
else      if(gb.display.solid[i].spritecol == port_noir) return true;
else      if(gb.display.solid[i].spritecol == rock_terrain_master) {gb.popup(F(" ""Rock"" "),1); return true;} //Return True if character have touched the wall
else      if(gb.display.solid[i].spritecol == rock_valley_ne) return true;
else      if(gb.display.solid[i].spritecol == rock_valley_nw) return true;
else      if(gb.display.solid[i].spritecol == rock_valley_se) return true;
else      if(gb.display.solid[i].spritecol == rock_valley_sw) return true;
else      if(gb.display.solid[i].spritecol == turtle_rock) return true;
else      if(gb.display.solid[i].spritecol == water_left_bottom) return true;
else      if(gb.display.solid[i].spritecol == water_left_middle) return true;
else      if(gb.display.solid[i].spritecol == water_left_top) return true;
else      if(gb.display.solid[i].spritecol == water_right_bottom) return true;
else      if(gb.display.solid[i].spritecol == water_right_middle) return true;
else      if(gb.display.solid[i].spritecol == water_right_top) return true;
else      if(gb.display.solid[i].spritecol == water_middle_bottom) return true;
else      if(gb.display.solid[i].spritecol == water_middle_middle) return true;
else      if(gb.display.solid[i].spritecol == water_middle_top) return true;
else      if(gb.display.solid[i].spritecol == rock_n) return true;
else      if(gb.display.solid[i].spritecol == rock_e) return true;
else      if(gb.display.solid[i].spritecol == rock_s) return true;
else      if(gb.display.solid[i].spritecol == rock_w) return true;
else      if(gb.display.solid[i].spritecol == bush_left) return true;
else      if(gb.display.solid[i].spritecol == bush_middle) return true;
else      if(gb.display.solid[i].spritecol == bush_right) return true;
//else      if(gb.display.solid[i].spritecol == bush_left) {gb.popup(F(" ""A bush!!"" "),1); return true;}
//else      if(gb.display.solid[i].spritecol == bush_middle) {gb.popup(F(" ""A bush!!"" "),1); return true;}
//else      if(gb.display.solid[i].spritecol == bush_right) {gb.popup(F(" ""A bush!!"" "),1); return true;}
else      if(gb.display.solid[i].spritecol == tree_base) return true;
else      if(gb.display.solid[i].spritecol == tree_repeat) return true;
else      if(gb.display.solid[i].spritecol == tree_top) return true;
else      if((gb.display.solid[i].spritecol == exit_1) && room == 1) {room = 2; player_x = 68; camerax = -52;}
else      if((gb.display.solid[i].spritecol == exit_1) && room == 2) {room = 1; player_x = 68; camerax = -52;}
else      if((gb.display.solid[i].spritecol == exit_1) && room == 3) {room = 2; player_y = 9; cameray = 0;}
else      if((gb.display.solid[i].spritecol == exit_1) && room == 5) {room = 1; player_y = 27; player_x = 59; camerax = -45; cameray = -21;}
else      if((gb.display.solid[i].spritecol == exit_2) && room == 1) {room = 2; player_x = 9; camerax = 0;}
else      if((gb.display.solid[i].spritecol == exit_2) && room == 2) {room = 1; player_x = 9; camerax = 0;}
else      if((gb.display.solid[i].spritecol == exit_3) && room == 2) {room = 3; player_y = 32; cameray = -40;}
else      if(gb.display.solid[i].spritecol == exit_4) return true;
else      if(gb.display.solid[i].spritecol == exit_5) return true;
else      if(gb.display.solid[i].spritecol == exit_6) return true;
else      if((gb.display.solid[i].spritecol == cave_ladder) && room ==3) {room = 4; player_x = 16; player_y = 24; camerax = 0; cameray = -48;}
else      if((gb.display.solid[i].spritecol == ladder) && room == 4) {room  = 3; player_x = 16; player_y = 24; camerax = 0; cameray = -48;}
else      if((gb.display.solid[i].spritecol == tombstone) && gb.buttons.repeat(BTN_A,1)) {gb.popup(F(" ""Here Lies Dave!"" "),1); return true;}
else      if(gb.display.solid[i].spritecol == tombstone) return true;
else      if(gb.display.solid[i].spritecol == WallB) return true;
else      if(gb.display.solid[i].spritecol == WallBL) return true;
else      if(gb.display.solid[i].spritecol == WallBR) return true;
else      if(gb.display.solid[i].spritecol == WallT) return true;
else      if(gb.display.solid[i].spritecol == WallTL) return true;
else      if(gb.display.solid[i].spritecol == WallTR) return true;
else      if(gb.display.solid[i].spritecol == WallL) return true;
else      if(gb.display.solid[i].spritecol == WallR) return true;
else      if(gb.display.solid[i].spritecol == houseB1) return true;
else      if(gb.display.solid[i].spritecol == houseB2) return true;
else      if((gb.display.solid[i].spritecol == houseB3) && room == 1) {room = 5; player_y = 32; player_x = 40; camerax = -0; cameray = -40;}
else      if(gb.display.solid[i].spritecol == houseB4) return true;
else      if(gb.display.solid[i].spritecol == houseB5) return true;
else      if(gb.display.solid[i].spritecol == houseT1) return true;
else      if(gb.display.solid[i].spritecol == houseT2) return true;
else      if(gb.display.solid[i].spritecol == houseT3) return true;
else      if(gb.display.solid[i].spritecol == houseT4) return true;
else      if(gb.display.solid[i].spritecol == houseT5) return true;
else      if(gb.display.solid[i].spritecol == roof1) return true;
else      if(gb.display.solid[i].spritecol == roof2) return true;
else      if(gb.display.solid[i].spritecol == roof3) return true;
else      if(gb.display.solid[i].spritecol == roof4) return true;
else      if(gb.display.solid[i].spritecol == roof5) return true;
else      if((gb.display.solid[i].spritecol == bedtop) && gb.buttons.repeat(BTN_A,1)) {gb.popup(F(" ""Aaah! My bed"" "),1); return true;}
else      if(gb.display.solid[i].spritecol == bedtop) return true;
else      if((gb.display.solid[i].spritecol == bedmid) && gb.buttons.repeat(BTN_A,1)) {gb.popup(F(" ""Aaah! My bed"" "),1); return true;}
else      if(gb.display.solid[i].spritecol == bedmid) return true;
else      if((gb.display.solid[i].spritecol == bedbottom) && gb.buttons.repeat(BTN_A,1)) {gb.popup(F(" ""Aaah! My bed"" "),1);}

  
      }
   }
    return false; // Return false if don't touch anything
  }
please ignore the button stuff for now. I just want to fix the switch.
 
Im trying to do a room switch using the collision functions ...

As it is your code confusing the compiler - it is making the most obvious notes it can on the confusing points. Break them down and get to the root of it.

The first two are warnings you should be able to resolve - unused var and PINK type not matching as it should. You should be able to clear those up. In this case they aren't the problem - unless he compiler makes the wrong 'guess' about the intent - but sometime a simple warning indicates a lurking larger problem. Any warning must be properly removed to trust the code.

The others all revolve around line 204. I can see it is missing an open parenthesis after the if . . . that is why the complaint about the ';' missing. When you see errors scan them all and if one like that looks 'ridiculous' start with that - when the parenthesis is balanced as intended - some or all of the other errors will go away or not be lost in code that can't compile giving four errors for a single line of code..

Before you do anything - hover over or select the parens and braces - it will be clear when it does matching that it is wrong. Also another simple thing is Ctrl+T in the IDE - it will uniformly reformat the code as is parses it - and where it gets confused will sometime be apparent. Sublimetext can do this as well - with Stino installed I mapped it to Ctrl+T. it will however typically break compressed multiline compaction back out onto multiple lines.
 
Ty ty ty!!!! Sometimes you just need a second pair of eyes. I stared at that for hours trying to figure out what the problem was. But I was concentrating on the rear of the code so I completely missed the parenthesis. SMH. So I fixed that and now when I hit the registered tile the map switches to a dungeon.

Don't really know what to do about the pink warning. The pink that comes with the library is a lil too pink and made my characters look funny so I changed it to a lighter pink to even it out. The new pink uses two more characters in its hex code so it's giving me the warning.
 
The compiler doesn't have eyes - just a mechanical expectation and response based on random text that fails to follow required syntax . . . indeed staring at the code can lead you nowhere - but the stumble by the compiler shows the line where problem developed - sometimes it happened before when something failed - but in this case it was there.

If you work at it and develop habits and process - clicking parens and braces for matches - scanning grouped errors until one rings a bell - back tracking each variable type and definition.

In the case of PINK you can't just extend it more hex characters. Alternate define should match the format and method used elsewhere. Only 16 bits are usable - which is 4 hex digits - anything longer than that forces it from some int_16 to some int_32. Within those 16 bits are values for R/G/B - anything outside that will be needlessly carried around until discarded or conflicting when it generates a warning - or bad behavior. When sign is involved it defaults to something and if that doesn't match the compiler warns when default handling runs up against a type that conflicts.
 
Also as noted - often syntax or other erros that confuse the compiler will also confuse the 'Auto Format' - as noted that is Ctrl+T in the IDE or Stino under Sublimetext 'Arduino / auto format'.

Save your code fist - then to the auto format - look for bad indents or other confusion created by that - then look to fix it - if it has destroyed desired formatting - UNDO ( or reload and discard those changes ) then make the fixes.
 
I also try to look top down at the errors. That is often the first error, will cause a cascade of errors to be shown, which actually may or may not be errors.
 
Yep i go from top to bottom. Ill have to try what you said about sublime text. See if tgat helps me. Still learning what it can do. Dont suppose you can reverse writing? This would make it easier to make people sprites using the arrays as i can draw the left character in bit code then reverse and copy and paste.

Decided to change out my tiles for some updated ones. A lil less 8 bit and more 16. After all im trying to show off what it can do.

Ok heres a question. Say i have a tall sprite or two stacked or what ever, and you want the player to walk behind it with out being seen. What would be the best way to do so? Seems like you could add them to collision and have a function written into the collision to mask the pixels going through it.
 
Say i have a tall sprite or two stacked or what ever, and you want the player to walk behind it with out being seen. What would be the best way to do so?
You would just change the order in which the items are drawn to the framebuffer. You draw the background, you draw your player sprite, you then draw the special item you can walk behind.
 
I finished all my updated terrain sprites last night. I think I broke a record on how many I can encode by hand in a day. But everything looks better.

Back to the popup.... ok I changed byte to integer and gave the screen size in the function the correct numbers. I think. after that I turned the map off then the buffer then wrote a simple function to display a popup when the A button is tapped. Nothing. I don't get it, it should at least show a round rectangle.

Code:
 void GrafxT3::popup(const __FlashStringHelper* text, uint8_t duration){
	popupText = text;
	popupTimeLeft = duration+12;
}

void GrafxT3::updatePopup(){
	if (popupTimeLeft){
		int yOffset = 0;
		if(popupTimeLeft<12){
			yOffset = 12-popupTimeLeft;
		}
		setTextSize(1);
//		setColor(WHITE);
		fillRoundRect(0,GrafxT3_TFTHEIGHT-textsize+yOffset-3,320,textsize+3,3,WHITE);
//		setColor(BLACK);
		drawRoundRect(0,GrafxT3_TFTHEIGHT-textsize+yOffset-3,320,textsize+3,3,BLACK);
		setCursor( 4, GrafxT3_TFTHEIGHT-textsize+yOffset-1);
		print(popupText);
		popupTimeLeft--;
	}
}
 
after that I turned the map off then the buffer

What did you do exactly? This leads me to believe you commented out the call to updateScreen and if you did then nothing will show on the screen. I think you left out this part
You need to call updatePopup at the end of all your drawing and before you call updateScreen.
 
Yep tried with out using the frameBuffer and update screen then tried with using those. Things show up with out using the frameBuffer and update screen. They are just flashy. Ok I have the update screen inside the void loop and the collision triggers outside the void loop. Will the update screen work outside the void loop?
 
Did you add updatePopup to your loop? I think you will need to update your github if I am to be of further help as I don't follow what you are saying. I can look tomorrow.
 
I shouldnt have to add update popup to the sketch. When ever i use it in its native library you use popup with your message. To be honest ive never seen update popup used in a sketch.


Ohhhhhhhhh i think i get it. I looked at the old library just now and saw that update popup is used in the updateAll function that we arent using. I could probably add it as a line to updatescreen(). Dense moment

Also updated the t3 library. Kind of waiting to make sure every thing works before i update the esp32 version.
 
Last edited:
how are you encoding your bitmaps btw? Im making a python script to encode my bitmaps into hex. So do you have a palette with 16 colors and then the bitmap data just indexes the pallete
 
Last edited:
What I did was name the palette colors one by one in the void loop so all the bitmaps use the same colors and integer numbers. I then use those integers/letters as bits then draw them out in hex by hand. I can do about 20 a day. Though over the weekend I broke my record with 60 some thing in 36 hours. But I have the color integers memorized so it doesn't take long. Tedious. Check out the dune demo on my github page all of the h files are full of bit maps. im actually having a problem with brown. I need 3. I need a dark brown a light brown and a beige. Beige and dark brown I have but the middle is getting to me. I can't remember how I made pink into a 0X0000 format using RGB. I stayed on google for a while today but when you say hex it only gives the values in #000000 which will not work. I even tried the RGB value but it showed up a weird blue color.


Any way so I tried putting the update popup function in several places but I can't get it to work. I set it to come up when ever it hit a common tile but nothing. Odd thing is if I make the action tile true as a solid with the pop up it won't be solid when you cross it.
 
I noted before - long ago now - if the encoding is a mechanical operation you could get the Teensy to do it in seconds if you have a data array to parse - just code the operations you do by hand and spew out printed values on SerMon and copy paste them back into the program. I don't recall that you considered that - or if there were any issues if tried - as that would be the sort of thing I'd be inclined to help refine as I have done it before and like stupid challenges where the computing power is made apparent and useful in a teachable moment. This is what basically what @awesome101 did with a python script.
 
I've been trying to play around with the popup function but the most I can get are what look like and act like glitches. Sometimes a couple colored horizontal lines will appear for a few seconds, other times it freezes the player but it all of this is random.

Another thing I noticed was that collision is still screwy. Not always colliding at the first pixel line of the object and goes half way through.
 
What is happening is that when you are saying tft.popup(F(" ""Rock"" "),1); in an if statement that popup function is being called consecutively frame after frame because the if statement is true when you touch the rock. You have to call the popup function only ONCE and then wait for the updatePopup to finish drawing the popup. To prevent this, change your popup functions to the below:
void GrafxT3::popup(const __FlashStringHelper* text, uint8_t duration){

* *if (popupTimeLeft < millis()) {
* *popupText = text;

* *popupTimeLeft = millis() + duration * 1000;
* *}

}



void GrafxT3::updatePopup(){

* *if (millis() < popupTimeLeft){

* ** *int yOffset = 0;

* ** *setTextSize(1);

//* ** *setColor(WHITE);

* ** *fillRoundRect(0,GrafxT3_TFTHEIGHT-textsize+yOffset-3,320,textsize+3,3,WHITE);

//* ** *setColor(BLACK);

* ** *drawRoundRect(0,GrafxT3_TFTHEIGHT-textsize+yOffset-3,320,textsize+3,3,BLACK);

* ** *setCursor( 4, GrafxT3_TFTHEIGHT-textsize+yOffset-1);

* ** *print(popupText);

* *}
 
Another thing I noticed was that collision is still screwy. Not always colliding at the first pixel line of the object and goes half way through.

Although your problem may be something else, I recommend you comment out all your collision checks that return false. The reason being if you are standing on sand for example you will return false and not be able to collide with anything you check after that in your code. It will only collide after you are completely off the sandy part.
 
ok I made a bigger world map at 308 x 308. when ever I try to compile using this pointer...

Code:
const byte duneworld[] = {308,308,
16,16,

I get this error....
Code:
Arduino: 1.8.2 (Windows 7), TD: 1.36, Board: "Teensy 3.6, Serial, 180 MHz, Faster, US English"

In file included from C:\Users\Duhjoker\Desktop\Dune32\Dune32.ino:11:0:

World.h:4321: error: narrowing conversion of '308' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,};

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      narrowing conversion of '308' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

so i changed byte to int8_t and then i get these errors

Code:
Dune32:213: error: no matching function for call to 'GrafxT3::drawTilemap(int&, int&, const int [94868], const byte* [183], uint16_t [16])'
   tft.drawTilemap(cameraX, cameraY, duneworld, spritesheet, palette);}

                                                                    ^

In file included from C:\Users\Duhjoker\Desktop\Dune32\Dune32.ino:6:0:

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3/GrafxT3.h:404:14: note: candidate: void GrafxT3::drawTilemap(int, int, const uint8_t*, const uint8_t**, const uint16_t*)

  void        drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet, const uint16_t * palette);

              ^

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3/GrafxT3.h:404:14: note:   no known conversion for argument 3 from 'const int [94868]' to 'const uint8_t* {aka const unsigned char*}'

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3/GrafxT3.h:405:14: note: candidate: void GrafxT3::drawTilemap(int, int, const uint8_t*, const uint8_t**, uint16_t, uint16_t, uint16_t, uint16_t, const uint16_t*)

  void        drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet, uint16_t dx, uint16_t dy, uint16_t dw, uint16_t dh, const uint16_t * palette);

              ^

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3/GrafxT3.h:405:14: note:   candidate expects 9 arguments, 5 provided

no matching function for call to 'GrafxT3::drawTilemap(int&, int&, const int [94868], const byte* [183], uint16_t [16])'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I think I need to change something else to int but not sure....
 
You need to learn proper c++ before you embark on such large projects. Byte means values of (0 - 255). you have 308 as one of your values. Change const byte duneworld[] = {308,308, to const int duneworld[]. also, did my new popup code work?
 
im trying to get there.....

im learning at least im trying to. Ok so when I change const byte to const int it gives me problems with the tilemap function saying no matching function so I have to change the const uint8t bitmap to const int bitmap, so change that and now I have to change some thing else. Im kind of in a circle now. I made these changes...................

Code:
void writeRectNBPP(int16_t x, int16_t y, int16_t w, int16_t h,  uint8_t bits_per_pixel, 
		const int *pixels, const uint16_t * palette );

	void writeRect4BPP(int16_t x, int16_t y, int16_t w, int16_t h, const int *pixels, const uint16_t * palette );
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
    void writeRect4BPPtm(int16_t x, int16_t y, int16_t w, int16_t h, const int *pixels, int dx, int dy, int dw, int dh, const uint16_t * palette );

and the cpp

Code:
void GrafxT3::writeRect4BPP(int16_t x, int16_t y, int16_t w, int16_t h, const int *pixels, const uint16_t * palette )
{
	// Simply call through our helper
	writeRectNBPP(x, y, w, h,  4, pixels, palette );
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void GrafxT3::writeRect4BPPtm(int16_t x, int16_t y, int16_t w, int16_t h, const int *pixels, int dx, int dy, int dw, int dh, const uint16_t * palette )
{
	dw += dx;
	dh += dy;{
	int largest = 0;
	int largesty = 0;
		int drawX = x;
				int drawY = y;

				if (drawX >= dx && drawX < dw && drawY >= dy && drawY < dh){
	// Simply call through our helper
	writeRectNBPP(x, y, w, h,  4, pixels, palette );
        }
    }
}
///============================================================================
// writeRectNBPP - 	write N(1, 2, 4, 8) bit per pixel paletted bitmap
//					bitmap data in array at pixels
//  Currently writeRect1BPP, writeRect2BPP, writeRect4BPP use this to do all of the work. 
void GrafxT3::writeRectNBPP(int16_t x, int16_t y, int16_t w, int16_t h,  uint8_t bits_per_pixel, 
		const int *pixels, const uint16_t * palette )
{
	//Serial.printf("\nWR8: %d %d %d %d %x\n", x, y, w, h, (uint32_t)pixels);
	x+=_originx;
	y+=_originy;
	uint8_t pixels_per_byte = 8/ bits_per_pixel;
	uint16_t count_of_bytes_per_row = (w + pixels_per_byte -1)/pixels_per_byte;		// Round up to handle non multiples
	uint8_t row_shift_init = 8 - bits_per_pixel;				// We shift down 6 bits by default 
	uint8_t pixel_bit_mask = (1 << bits_per_pixel) - 1; 		// get mask to use below
	// Rectangular clipping 

	// See if the whole thing out of bounds...
	if((x >= _displayclipx2) || (y >= _displayclipy2)) return;
	if (((x+w) <= _displayclipx1) || ((y+h) <= _displayclipy1)) return;

	// In these cases you can not do simple clipping, as we need to synchronize the colors array with the
	// We can clip the height as when we get to the last visible we don't have to go any farther. 
	// also maybe starting y as we will advance the color array. 
	// Again assume multiple of 8 for width
 	if(y < _displayclipy1) {
 		int dy = (_displayclipy1 - y);
 		h -= dy; 
 		pixels += dy * count_of_bytes_per_row;
 		y = _displayclipy1; 	
 	}

	if((y + h - 1) >= _displayclipy2) h = _displayclipy2 - y;

	// For X see how many items in color array to skip at start of row and likewise end of row 
	if(x < _displayclipx1) {
		uint16_t x_clip_left = _displayclipx1-x; 
		w -= x_clip_left; 
		x = _displayclipx1; 
		// Now lets update pixels to the rigth offset and mask
		uint8_t x_clip_left_bytes_incr = x_clip_left / pixels_per_byte;
		pixels += x_clip_left_bytes_incr;
		row_shift_init = 8 - (x_clip_left - (x_clip_left_bytes_incr * pixels_per_byte) + 1) * bits_per_pixel; 	
	}

	if((x + w - 1) >= _displayclipx2) {
		w = _displayclipx2  - x;
	} 

	const uint8_t * pixels_row_start = pixels;  // remember our starting position offset into row

	#ifdef ENABLE_GrafxT3_FRAMEBUFFER
	if (_use_fbtft) {
		uint16_t * pfbPixel_row = &_pfbtft[ y*_width + x];
		for (;h>0; h--) {
			uint16_t * pfbPixel = pfbPixel_row;
			pixels = pixels_row_start;				// setup for this row
			uint8_t pixel_shift = row_shift_init;			// Setup mask

			for (int i = 0 ; i < w; i++) {
///				*pfbPixel++ = palette[((*pixels)>>pixel_shift) & pixel_bit_mask];
				uint8_t palette_index = ((*pixels)>>pixel_shift) & pixel_bit_mask;
                if (palette_index != TRANSPARENT_INDEX)
                *pfbPixel = palette[palette_index];
                *pfbPixel++;
				if (!pixel_shift) {
					pixel_shift = 8 - bits_per_pixel;	//setup next mask
					pixels++;
				} else {
					pixel_shift -= bits_per_pixel;
				}
			}
			pfbPixel_row += _width;
			pixels_row_start += count_of_bytes_per_row;
		}
		return;	

	}
	#endif

///////////////////////////////////////////////////////////////////
/*	beginSPITransaction();
	setAddr(x, y, x+w-1, y+h-1);
	writecommand_cont(GrafxT3_RAMWR);
	for (;h>0; h--) {
		pixels = pixels_row_start;				// setup for this row
		uint8_t pixel_shift = row_shift_init;			// Setup mask

		for (int i = 0 ;i < w; i++) {
			writedata16_cont(palette[((*pixels)>>pixel_shift) & pixel_bit_mask]);
			if (!pixel_shift) {
				pixel_shift = 8 - bits_per_pixel;	//setup next mask
				pixels++;
			} else {
				pixel_shift -= bits_per_pixel;
			}
		}
		pixels_row_start += count_of_bytes_per_row;
	}
	writecommand_last(GrafxT3_NOP);
	endSPITransaction();*/
////////////////////////////////////////////////////////////////////
///for transparent pixels
	beginSPITransaction();
	for (;h>0; h--) {
		pixels = pixels_row_start;				// setup for this row
		uint8_t pixel_shift = row_shift_init;			// Setup mask
                int16_t x_out = x; 
		for (int i = 0 ;i < w; i++) {
			uint8_t palette_index = ((*pixels)>>pixel_shift) & pixel_bit_mask;
			if (palette_index != TRANSPARENT_INDEX)
				Pixel(x_out, y, palette[palette_index]);
			if (!pixel_shift) {
				pixel_shift = 8 - bits_per_pixel;	//setup next mask
				pixels++;
			} else {
				pixel_shift -= bits_per_pixel;
			}
			x_out++;
		}
		pixels_row_start += count_of_bytes_per_row;
		y++;
	}
	endSPITransaction();
}

and here are the error messages I cant figure out since every thing matches

Code:
Arduino: 1.8.2 (Windows 7), TD: 1.36, Board: "Teensy 3.6, Serial, 180 MHz, Faster, US English"


C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp: In member function 'void GrafxT3::writeRect2BPP(int16_t, int16_t, int16_t, int16_t, const uint8_t*, const uint16_t*)':

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:2953:48: error: no matching function for call to 'GrafxT3::writeRectNBPP(int16_t&, int16_t&, int16_t&, int16_t&, int, const uint8_t*&, const uint16_t*&)'

  writeRectNBPP(x, y, w, h,  2, pixels, palette );

                                                ^

In file included from C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:50:0:

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.h:551:7: note: candidate: void GrafxT3::writeRectNBPP(int16_t, int16_t, int16_t, int16_t, uint8_t, const int*, const uint16_t*)

  void writeRectNBPP(int16_t x, int16_t y, int16_t w, int16_t h,  uint8_t bits_per_pixel, 

       ^

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.h:551:7: note:   no known conversion for argument 6 from 'const uint8_t* {aka const unsigned char*}' to 'const int*'

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp: In member function 'void GrafxT3::writeRect1BPP(int16_t, int16_t, int16_t, int16_t, const uint8_t*, const uint16_t*)':

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:2965:48: error: no matching function for call to 'GrafxT3::writeRectNBPP(int16_t&, int16_t&, int16_t&, int16_t&, int, const uint8_t*&, const uint16_t*&)'

  writeRectNBPP(x, y, w, h,  1, pixels, palette );

                                                ^

In file included from C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:50:0:

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.h:551:7: note: candidate: void GrafxT3::writeRectNBPP(int16_t, int16_t, int16_t, int16_t, uint8_t, const int*, const uint16_t*)

  void writeRectNBPP(int16_t x, int16_t y, int16_t w, int16_t h,  uint8_t bits_per_pixel, 

       ^

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.h:551:7: note:   no known conversion for argument 6 from 'const uint8_t* {aka const unsigned char*}' to 'const int*'

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp: In member function 'void GrafxT3::writeRectNBPP(int16_t, int16_t, int16_t, int16_t, uint8_t, const int*, const uint16_t*)':

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:3018:37: error: cannot convert 'const int*' to 'const uint8_t* {aka const unsigned char*}' in initialization

  const uint8_t * pixels_row_start = pixels;  // remember our starting position offset into row

                                     ^

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:3025:11: error: cannot convert 'const uint8_t* {aka const unsigned char*}' to 'const int*' in assignment

    pixels = pixels_row_start;    // setup for this row

           ^

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:3033:28: warning: value computed is not used [-Wunused-value]

                 *pfbPixel++;

                            ^

C:\Users\Duhjoker\Documents\Arduino\libraries\GameR-Iot_T3\GrafxT3.cpp:3074:10: error: cannot convert 'const uint8_t* {aka const unsigned char*}' to 'const int*' in assignment

   pixels = pixels_row_start;    // setup for this row

          ^

Error compiling for board Teensy 3.6.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 
Status
Not open for further replies.
Back
Top