Using frame buffering to solidify tft displayed objects

Status
Not open for further replies.
I think you should remove all your changes to the writeRect functions. I don't see why they should change.
I suggest you use int16_t instead of int in your changes. I would expect the int to be 32 bits, so you have increased the storage requirement of your array to 4 times what is was before with your change just to accommodate two values that are larger than a byte. int16_t will be two times the storage space.

And if it were mine I would probably not make hardly any changes at all and leave it as byte size. Instead I would code the 308 as two bytes ( as 1,52 ) in your array and in the drawTilemap function have just some simple changes where it picks up the size information. Something like:

Code:
const byte duneworld[] = {1,52,1,52,
16,16,
Code:
uint16_t tilemap_width = pgm_read_byte(tilemap)* 256 + pgm_read_byte(tilemap + 1) ;
	uint16_t tilemap_height = pgm_read_byte(tilemap + 2)* 256 + pgm_read_byte(tilemap + 3);
	uint16_t tile_width = pgm_read_byte(tilemap + 4);
	uint16_t tile_height = pgm_read_byte(tilemap + 5);
tilemap += 6; // now the first tiyleis at tilemap
 
Last edited:
Yea some thing is really wrong. I ended up having to change too many things to int from int16_t doing it that way. Now it compiles but takes up 50% of my flash. So now I'm going to change every thing back. Fortunately I haven't exited out of sublime since I started today so I just have to hold control z and try what you said.
 
Ok I got your fix to work though can you please explain the math for the 1,52,1,52,? It uses much less space but it's still double the space that it should be compiling what I'm compiling. Also causes the the top horizontal row of 16x16 to not clear. Same with the far left vertical column

What would be a better way of fixing it so it uses the lowest amount of space as before?

Edit::

Still nothing on the popup. I guess I can split my world up into sections that connect and slide the other map in when it reaches the end of its domain. This would also make it easier to assign monsters to different sections like most RPG's. Will also make it easier to make changes.

Edit::

I did some playing around with my tile map and gave it a total width and height of 458 X 458. The extra eight cover a border that's 4 thick each side. Split that up and I get 9 150 x150 maps. Now what I'll do is make a tile for each inside boarder that will then slide which ever map into place. The character should appear in the same X and Y of the previous map.

Edit::

Splitting the maps up means multiple entrance/exit tiles to get the player to be where he was and where he should be.

So I need to figure out how to do this with out using so much space.
 
Last edited:
Heres a question.....

We all know by now how the collision works and can be used to trigger room changes. Ok so now i have a room 50 x 50 tiles and i want to be able to walk to the edge and change to room 2. Now the exit tile is told at that point where to spit you out.

I wondering if there is way to repeat that tile where if i touch it at these coordinates its gonna spit me out here. But if i hit the same tile at this different coordinate and spit me out at that different coordinate.

Im trying to figure out how to make splitting the maps feasable without adding 150 exit tiles physically to flash. If i could use the same tile multiple times to send the player to its opposite side when the map changes. Other wise i would have to make each change spit the character out at 1 to 3 spots which will annoy players if they accidentally hit the tile and have to back track to be where they were.

But then id have to right it 150x per side which would take forever.
 
Last edited:
Earlier when i changed EVERY THING to int instead of uint16_t in the write rect functiins and buffer and got it to compile. It did display the character fine but the tile map was scruched up like a wide screen and was random pixels. But it was also still using 8% instead of 16%.
 
The math for the 1,52 is pretty simple. 256 + 52 = 308. If you now want a tile map less than 256 by 256 you will need a zero as the first of the two numbers. For example :

Code:
const byte dune_demo[] = {0,150,0,150,
16,16,

The intent may be clearer if you let the compiler do the math and code as:

Code:
const byte dune_demo[] = {308/256, 308%256, 308/256, 308%256,
16,16,

Or for a smaller tilemap:

Code:
const byte dune_demo[] = {150/256, 150%256, 150/256, 150%256,
16,16,

My message above was describing two different ideas, so if you go with this you would not change anything to int16_t and leave all the functions in the library the same except for the few lines of code above.
 
So this code is not working:
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);

}

If it's not, I don't really know. There could be several problems like maybe your graphics functions are not working or you are updating the screen before you call updatePopup() so the popup graphics are never seen.
 
First get rid of all your updatePopup functions. Then, Just before you call updateScreen say print(F("Hi");
If you don't see something or it glitches or something there is a problem with your graphics functions
 
Ok so is there a way to do the map so it doesn't take up twice the amount of space?

Trippy!!! So I changed every thing back to the way I originally had it set up and added your code above to the tile map and it works with out changing any thing in the library.

I still don't understand why the storage rate is so high though.
 
Last edited:
Ok guys. Sorry had to start over again with my library I forgot what all I had changed and it caused some weird effects so I had to start from my last github save. I then restructured my world maps so I have a block of 9 rooms. 3x3x3. So first I took all my land masses in each sector and separated them into a room for each. Each sector room gets a stone and barrier border that wraps around it. I'm starting with the top center of the block and gave it 3 exits. Exit west, exit south and exit east. Now I can put the rest of the game together in modules for ease of convenience. The map will have a Zelda-ish feel but I'm happy for now.

I made a mini map as well as for a button controlled option that lets you travel the mini map either by worm or by a shortcut so you don't have to scroll through all the maps to get to your final destination. For the worm I was thinking something like option: throw thumper...... When the worm comes to kill the thumper a mini game bubble can appear where you have to hit a series of buttons to catch it. Once caught you can travel quickly through the mini map.

I think I did a pretty good job on the mini maps avatars. It was kinda difficult but only because I have to switch between Windows to make sure each avatar looks close enough to its counterpart with out looking cheesy. But I love the art of forced perspective.

Awesome101...... I was calling the new function update trippy. Only because it's a new way of doing something that I had never thought of. How is your build coming?

I also figured out the 16% was because that's how much content it was playing with. Right now with 21 rooms it's at 12% but take in mind I have monsters and main characters as well included in my sketch.

I have tried the popup feature again with no results. Gonna try and get around to running a serial print with my new cord and see what's happening when I hit a rock wall. The collision part I know works but I also need to try and print out a round rectangle and see what's up with that.
 
Last edited:
Wait...... The pop up function assumes that you have a font already set. Whence set text size set text color yada yada. I know I don't have a font set in my sketch but I can't remember if it's set in the library. Might be easier to just do it manually. Think I might try that.

Edit:: ok just checked and I do not have set font with in any of the functions in my .cpp file. Only place set font can be found is in the header under text
 
Last edited:
I have new user for my system that would like to use the ESP32 library. But I don't have the transparent index set up for it. I would like to do that and thought I could just right it in but Kurt has the nbpp function set up a lil differently. Can some one take a look and advise me on how to proceed please?

here are kurts fixes for the t3 library....
Code:
void GrafxT3::writeRectNBPP(int16_t x, int16_t y, int16_t w, int16_t h,  uint8_t bits_per_pixel, 
		const uint8_t *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 is the nbpp for the esp32 library he helped me with....
Code:
void Grafx_esp::writeRectNBPP(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t bits_per_pixel,
	const uint8_t *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_Grafx_FRAMEBUFFER
	if (_use_fbtft) {
		for (; h>0; h--) {
			uint16_t * pfbPixel = mapYtoFBPtr(y) + x;
			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++ = FBmapColor(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;
				}
			}
			y++;
			pixels_row_start += count_of_bytes_per_row;
		}
		return;

	}
#endif

	beginSPITransaction();
	setAddr(x, y, x + w - 1, y + h - 1);
	writecommand_cont(Grafx_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(Grafx_NOP);
	endSPITransaction();
}


as you can see here it has the map to fb variables and the original doesn't....

Code:
#ifdef ENABLE_Grafx_FRAMEBUFFER
	if (_use_fbtft) {
		for (; h>0; h--) {
			uint16_t * pfbPixel = mapYtoFBPtr(y) + x;
			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++ = FBmapColor(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;
				}
			}
			y++;
			pixels_row_start += count_of_bytes_per_row;
		}
		return;

	}
#endif
 
I was able to figure out how to transcribe the trams parent pixels over after I gave it another look.

I'm having trouble including files. I'm trying to work out an example of how to draw battle screens for RPG random battles and it includes some text features. It's got a text file for including text bubbles and a variables files and the battle file. I tried putting the two character files together but it was problem after problem running in circles trying to get the functions and variables in the right order. So instead I'm doing it the way the original program calls for. But it won't include the files to each other and gives me not declared errors because thier not reading each other.

I'm using #include "text.h" but nothing.

It's not giving me errors that the file is not included it's just not including the stuff in the h files.
 
We will come back to the above. I followed your advice and removed any false tile from the collision list and now every thing is solid to a T!
 
Ive been trying to learn more c++ but so far I'm just reviewing what I already know.

ok I have problem. I want to turn my main sketch which is just player controls into a header and calling the loop void player or what ever. Then I can build my functions and call them peperly through a void loop. ive managed to get it all separated but for some reason I get these errors for collision not being declared. ive tried a quite afew things but it just wont let me compile. can some one please take a look and give me hint of what could be causing the problem.

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

Player.h:244: error: 'checkcolision' was not declared in this scope
      if(checkcolision())

                       ^

Player.h:257: error: 'checkcolision' was not declared in this scope
     if(checkcolision())

                      ^

Player.h:270: error: 'checkcolision' was not declared in this scope
    if(checkcolision())

                     ^

Player.h:283: error: 'checkcolision' was not declared in this scope
   if(checkcolision())

                    ^

Multiple libraries were found for "Bounce.h"
 Used: C:\Users\Duhjoker\Documents\Arduino\libraries\Bounce
 Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Bounce
'checkcolision' was not declared in this scope

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


here is the header file....

Code:
#ifndef _player_H_
#define _player_H_

#include "Bitmaps.h"
#include "world.h"
//#include 
int animTransition;
int room = 1;   ///////starting room 
int co_ords = 1;

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////Button assignments//////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//////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

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Camera offset
int cameraX = -1014;  /////starting position X 0f camera on tilemap 
int cameraY = -1136;  /////starting position Y of camera on tilemap

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

// Camera offset boundaries
int cameraXMin = -2080;   /////// -320 0f total tilemap pixels x right >>>>
int cameraXMax = 0;
int cameraYMin = -2144;   /////// -256 0f total tilemap pixels y down VVVV
int cameraYMax = 0;

 int player_x = 122;     //player position on screen x
 int player_y = 188;     //player position on screen y
 int player_direction = 2;
// int x=-0,y=0;

// Player offset boundaries allows camera to scroll when player moves to boundary 
int playerXMin = 80;    //////// do not change if resolution of tft is 320x240
int playerXMax = 240;    
int playerYMin = 80;
int playerYMax = 160;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
extern GrafxT3 tft;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////Loop////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void drawplayer() {

///////////////////////////////////////////////////////////////////////////////
////////////////////////////////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;
  }
}
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////Palette////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
 palette[0] = 0;
       palette[1] = BLACK;
             palette[2] = BLUE;
                   palette[3] = BROWN;
                         palette[4] = DARKGREEN;
                              palette[5] = GREY;
                                    palette[6] = PINK;
                                          palette[7] = RED;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////                                                
                                           palette[8] = BEIGE;
                                     palette[9] = GREEN;
                               palette[a]= DARKGREY;
                         palette[b] = LIGHTGREY;
                   palette[c] = YELLOW; 
             palette[d] = PURPLE; 
       palette[e] = WHITE;
 palette[f] = ORANGE;

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////Tilemap/////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/////// top center rock formation
      if(room == 1){
  tft.drawTilemap(cameraX, cameraY, dunewtopcenter, spritesheet, palette);}
 else if(room == 2){
  tft.drawTilemap(cameraX, cameraY, dungeon1l1, spritesheet, palette);}
 else if(room == 3){
  tft.drawTilemap(cameraX, cameraY, dungeon1l2, spritesheet, palette);}
 else if(room == 4){
  tft.drawTilemap(cameraX, cameraY, dungeon1l3, spritesheet, palette);}
 else if(room == 5){
  tft.drawTilemap(cameraX, cameraY, dungeon2l1, spritesheet, palette);}
 else if(room == 6){
  tft.drawTilemap(cameraX, cameraY, dungeon2l2, spritesheet, palette);}
 else if(room == 7){
  tft.drawTilemap(cameraX, cameraY, dungeon2l3, spritesheet, palette);}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////seitch village1  
 else if(room == 8){
  tft.drawTilemap(cameraX, cameraY, seitchv1, spritesheet, palette);} 
 else if(room == 9){
  tft.drawTilemap(cameraX, cameraY, seitch1r1l1, spritesheet, palette);}
 else if(room == 10){
  tft.drawTilemap(cameraX, cameraY, seitch1r1l2, spritesheet, palette);}
 else if(room == 11){
  tft.drawTilemap(cameraX, cameraY, seitch1r2, spritesheet, palette);}
 else if(room == 12){
  tft.drawTilemap(cameraX, cameraY, seitch1r3, spritesheet, palette);}
 else if(room == 13){
  tft.drawTilemap(cameraX, cameraY, seitch1r4shop, spritesheet, palette);}
 else if(room == 14){
  tft.drawTilemap(cameraX, cameraY, seitch1r5, spritesheet, palette);}
 else if(room == 15){
  tft.drawTilemap(cameraX, cameraY, seitch1r6, spritesheet, palette);}
 else if(room == 16){
  tft.drawTilemap(cameraX, cameraY, seitch1r7, spritesheet, palette);} 
 else if(room == 17){
  tft.drawTilemap(cameraX, cameraY, seitch1r8, spritesheet, palette);}
 else if(room == 18){
  tft.drawTilemap(cameraX, cameraY, seitch1r91011, spritesheet, palette);}
 else if(room == 19){
  tft.drawTilemap(cameraX, cameraY, seitch1r1213, spritesheet, palette);}
 else if(room == 20){
  tft.drawTilemap(cameraX, cameraY, seitch1r14, spritesheet, palette);}
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
/////////////seitch village2
 else if(room == 21){
  tft.drawTilemap(cameraX, cameraY, seitchv2, spritesheet, palette);}
 else if(room == 22){
  tft.drawTilemap(cameraX, cameraY, seitch2r1shop, spritesheet, palette);}
 else if(room == 23){
  tft.drawTilemap(cameraX, cameraY, seitch2r2, spritesheet, palette);}
 else if(room == 24){
  tft.drawTilemap(cameraX, cameraY, seitch2r3, spritesheet, palette);}
 else if(room == 25){
  tft.drawTilemap(cameraX, cameraY, seitch2r4, spritesheet, palette);}
 else if(room == 26){
  tft.drawTilemap(cameraX, cameraY, seitch2r5, spritesheet, palette);}
 else if(room == 27){
  tft.drawTilemap(cameraX, cameraY, seitch2r6, spritesheet, palette);}
 else if(room == 28){
  tft.drawTilemap(cameraX, cameraY, seitch2r78, spritesheet, palette);}
 else if(room == 29){
  tft.drawTilemap(cameraX, cameraY, seitch2r910, spritesheet, palette);}
  
///////////////////////////////////////////////////////////////////////////////
///////////////////////////Buttons Repeat//////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////  
       if (ButtonUp.update());
               if (ButtonDown.update());
                       if (ButtonLeft.update());
                             if (ButtonRight.update());
                                       if (ButtonA.update());
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
                                       ButtonUp.rebounce(10);
                               ButtonDown.rebounce(10);
                       ButtonLeft.rebounce(10);
            ButtonRight.rebounce(10);
     ButtonA.rebounce(10);
///////////////////////////////////////////////////////////////////////////////
////////////////////////////Up/////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
 if (ButtonUp.fallingEdge()){
     tft.writeRectNBPP(player_x, player_y,16,16,4,paulrearw,palette);
     player_direction = 1;
     player_y -= 4;
     if(checkcolision())
     {
      player_y += 4;} 
     }
     if(player_y <= 16){
        player_y = 16;}
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////Down///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
 if (ButtonDown.fallingEdge()){
   tft.writeRectNBPP(player_x, player_y,16,16,4,paulfrontw,palette);
   player_direction = 2;
   player_y += 4;
    if(checkcolision())
    {
    player_y -=4;}
    }
    if(player_y >= 224){
       player_y = 224;}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////Left////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
 if (ButtonLeft.fallingEdge()){
   tft.writeRectNBPP(player_x, player_y,16,16,4,paulleftw,palette);
   player_direction = 3;
   player_x -= 4;
   if(checkcolision())
   {
      player_x += 4;}  
   }
   if(player_x >= 304){
      player_x = 304;}
/////////////////////////////////////////////////////////////////////////////
////////////////////////////Right////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
if (ButtonRight.fallingEdge()){
  tft.writeRectNBPP(player_x, player_y,16,16,4,paulrightw,palette);
  player_direction = 4;
  player_x += 4;
  if(checkcolision())
  {
    player_x -= 4;}
  }
            if(player_x <= 16){
              player_x = 16;}
///////////////////////////////////////////////////////////////////////////////     
//////////////////////////////PLAYER DIRECTION/////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
if (player_direction == 1){
  tft.writeRectNBPP(player_x, player_y,16,16,4,paulrear,palette);
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
else if (player_direction == 2){
   tft.writeRectNBPP(player_x, player_y,16,16,4,paulfront,palette);
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
else if (player_direction == 3){
    tft.writeRectNBPP(player_x, player_y,16,16,4,paulleft,palette);
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
else if (player_direction == 4){
     tft.writeRectNBPP(player_x, player_y,16,16,4,paulright,palette);
        }
        tft.updatePopup();
        tft.updateScreen(); 
};     
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////collision/////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
bool checkcolision(void) // Transformed it into a function 
{
  for(uint16_t i=0; i < tft.numcolision + 1; i++)
  {
    if(tft.collideRectRect(player_x, player_y,16,16,tft.solid[i].x,tft.solid[i].y,16,16))
    {
        if(tft.solid[i].spritecol == bedtop)return true;
   else if(tft.solid[i].spritecol == bedbot)return true;
   else if(tft.solid[i].spritecol == bones11)return true;
   else if(tft.solid[i].spritecol == bones12)return true;
   else if(tft.solid[i].spritecol == bones13)return true;
   else if(tft.solid[i].spritecol == bones21)return true; 
   else if(tft.solid[i].spritecol == bones22)return true;
   else if(tft.solid[i].spritecol == bones23)return true;
   else if(tft.solid[i].spritecol == bookstop )return true;
   else if(tft.solid[i].spritecol == booksbot)return true; 
   else if(tft.solid[i].spritecol == cabtop)return true;
   else if(tft.solid[i].spritecol == cabbot)return true;
   else if(tft.solid[i].spritecol == cactus)return true;
   else if(tft.solid[i].spritecol == chimneytop)return true;
   else if(tft.solid[i].spritecol == chimneybot)return true;
   else if(tft.solid[i].spritecol == couchtop)return true;
   else if(tft.solid[i].spritecol == couchbot)return true;
   else if(tft.solid[i].spritecol == dish11)return true;
   else if(tft.solid[i].spritecol == dish12)return true;
   else if(tft.solid[i].spritecol == dish13)return true;
   else if(tft.solid[i].spritecol == dish21)return true;
   else if(tft.solid[i].spritecol == dish22)return true;
   else if(tft.solid[i].spritecol == dish23)return true;
   else if(tft.solid[i].spritecol == dish31)return true;
   else if(tft.solid[i].spritecol == dish32)return true;
   else if(tft.solid[i].spritecol == dish33)return true;
   else if(tft.solid[i].spritecol == machine1t)return true;
   else if(tft.solid[i].spritecol == machine1b)return true; 
   else if(tft.solid[i].spritecol == machine2t)return true;
   else if(tft.solid[i].spritecol == machine2b)return true;
   else if(tft.solid[i].spritecol == machine311)return true;
   else if(tft.solid[i].spritecol == machine312)return true;
   else if(tft.solid[i].spritecol == machine313)return true;
   else if(tft.solid[i].spritecol == machine321)return true;
   else if(tft.solid[i].spritecol == machine322)return true;
   else if(tft.solid[i].spritecol == machine323)return true;
   else if(tft.solid[i].spritecol == machine331)return true;
   else if(tft.solid[i].spritecol == machine332)return true;
   else if(tft.solid[i].spritecol == machine333)return true; 
   else if(tft.solid[i].spritecol == mart)return true; 
   else if(tft.solid[i].spritecol == palmtl)return true;
   else if(tft.solid[i].spritecol == palmtr)return true;
   else if(tft.solid[i].spritecol == palmbl)return true;
   else if(tft.solid[i].spritecol == palmbr)return true;
   else if(tft.solid[i].spritecol == pot)return true;
   else if(tft.solid[i].spritecol == printerl)return true;
   else if(tft.solid[i].spritecol == printerr)return true;
   else if(tft.solid[i].spritecol == ptreetop)return true;
   else if(tft.solid[i].spritecol == ptreebot)return true;
   else if(tft.solid[i].spritecol == rocktopcap)return true;
   else if(tft.solid[i].spritecol == rockbotcap)return true;
   else if(tft.solid[i].spritecol == rockleftcap)return true;
   else if(tft.solid[i].spritecol == rockrightcap)return true;
   else if(tft.solid[i].spritecol == rockcornertl)return true;
   else if(tft.solid[i].spritecol == rockcornertr)return true;
   else if(tft.solid[i].spritecol == rockcornerbl)return true;
   else if(tft.solid[i].spritecol == rockcornerbr)return true;
   else if(tft.solid[i].spritecol == rockcornersharptl)return true;
   else if(tft.solid[i].spritecol == rockcornersharptr)return true;
   else if(tft.solid[i].spritecol == rockcornersharpbl)return true;
   else if(tft.solid[i].spritecol == rockcornersharpbr)return true;
   else if(tft.solid[i].spritecol == rockendl)return true;
   else if(tft.solid[i].spritecol == rockendr)return true;
   else if(tft.solid[i].spritecol == rockwalllc)return true;
   else if(tft.solid[i].spritecol == rockwallrc)return true;
   else if(tft.solid[i].spritecol == rockwall){tft.popup(F(" ""Rock"" "),3); return true;}
   else if(tft.solid[i].spritecol == stonewall)return true;
   else if(tft.solid[i].spritecol == tablel)return true;
   else if(tft.solid[i].spritecol == tabler)return true;
   else if(tft.solid[i].spritecol == tablesm)return true;
   else if(tft.solid[i].spritecol == tomb)return true;
   else if(tft.solid[i].spritecol == water)return true;
//////////////////////////////////////////////////////////////////////////////////////////// 
////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////Action Tiles/////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////// top center rock formation
 else if(tft.solid[i].spritecol == areaexitw1)return true;
 else if(tft.solid[i].spritecol == areaexits1)return true;
 else if(tft.solid[i].spritecol == areaexite1)return true;
 else if((tft.solid[i].spritecol == cave1) && room == 1){room = 2; player_x = 96; player_y = 188;  cameraX = 0; cameraY = -480; cameraYMin = -480; cameraXMin = -0;}
 else if((tft.solid[i].spritecol == exit1) && room == 2){room = 1; player_x = 160; player_y = 176; cameraX = -928; cameraY = -1728; cameraXMin = -2080; cameraYMin = -2144; cameraXMax = -0; cameraYMax = -0;} 
 else if((tft.solid[i].spritecol == stairsl1) && room == 2){room = 3; player_x = 256;  player_y = 172; cameraX = 0; cameraY = -480; cameraYMin = -480; cameraXMin = -0;}
 else if((tft.solid[i].spritecol == stepsleft1) && room == 3){room = 2; player_x = 256; player_y = 80; cameraX = 0; cameraY = 0; cameraYMin = -480; cameraXMin = -0;}
 else if((tft.solid[i].spritecol == stairsl2) && room == 3){room = 4; player_x = 160; player_y = 256; cameraX = -0; cameraY = -64; cameraYMin = -192; cameraXMin = -80; cameraXMax = -0; cameraYMax = 0;} 
 else if((tft.solid[i].spritecol == stepsleft2) && room == 4){room = 3; player_x = 288; player_y = 96; cameraX = 0; cameraY = 0; cameraYMin = -480; cameraXMin = -0;}
 else if((tft.solid[i].spritecol == exit2) && room == 4){room = 1; player_x = 128; player_y = 204; cameraX = -944; cameraY = -1504; cameraXMin = -2080; cameraYMin = -2144; cameraXMax = 0; cameraYMax = 0;}
 else if((tft.solid[i].spritecol == cave2) && room == 1){room = 4; player_x = 288; player_y = 176; cameraX = -48; cameraY = -192; cameraYMin = -192; cameraXMin = -80; cameraXMax = -0; cameraYMax =0;}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 else if((tft.solid[i].spritecol == cave3) && room == 1){room = 5; player_x = 128; player_y = 188;  cameraX = -16; cameraY = -480; cameraYMin = -480; cameraXMin = -80;}
 else if((tft.solid[i].spritecol == exit3) && room == 5){room = 1;  player_x = 128; player_y = 204; cameraX = -1120; cameraY = -1280; cameraXMin = -2080; cameraYMin = -2144; cameraXMax = 0; cameraYMax = 0;} 
 else if((tft.solid[i].spritecol == stairsl3) && room == 5){room = 6; player_x = 216; player_y = 80; cameraX = -0; cameraY = -0; cameraYMin = -192; cameraXMin = -80; cameraXMax = -0; cameraYMax =0;}
 else if((tft.solid[i].spritecol == stepsleft3) && room == 6){room = 5;  player_x = 256; player_y = 64; cameraX = -80; cameraY = -0; cameraYMin = -192; cameraXMin = -80;}
 else if((tft.solid[i].spritecol == stairsl4) && room == 6){room = 7; player_x = 288; player_y = 185; cameraX = -0; cameraY = -192; cameraYMin = -192; cameraXMin = -80; cameraXMax = -0; cameraYMax = 0;} 
 else if((tft.solid[i].spritecol == stepsleft4) && room == 7){room = 6; player_x = 288; player_y = 176; cameraX = -0; cameraY = -64; cameraYMin = -192; cameraXMin = -80; cameraXMax = -0; cameraYMax = 0;} 
 else if((tft.solid[i].spritecol == stairsl5) && room == 7){room = 1; player_x = 288; player_y = 176; cameraX = -848; cameraY = -1312; cameraXMin = -2080; cameraYMin = -2144; cameraXMax = -0; cameraYMax = -0;} 
 else if((tft.solid[i].spritecol == stepsleft5) && room == 1){room = 7; player_x = 128; player_y = 80; cameraX = -0; cameraY = -0; cameraYMin = -192; cameraXMin = -80; cameraXMax = -0; cameraYMax = 0;} 
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////seitch village 1
 else if((tft.solid[i].spritecol == seitch1) && room == 1){room = 8; player_x = 160; player_y = 188; cameraX = -320; cameraY = -592; cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == exit4) && room == 8){room = 1;  player_x = 128; player_y = 188; cameraX = -864; cameraY = -832;  cameraXMin = -2080; cameraYMin = -2144; cameraXMax = -0; cameraYMax = -0;} 
 else if((tft.solid[i].spritecol == cave4) && room == 8){room = 9; player_x = 160; player_y = 188; cameraX = -0; cameraY = -160; cameraYMin = -161; cameraXMin = -80;}
 else if((tft.solid[i].spritecol == exit5) && room == 9){room = 8;  player_x = 112; player_y = 188; cameraX = -368; cameraY = -480; cameraYMin = -720; cameraXMin = -640;}
 else if((tft.solid[i].spritecol == stepsleft6) && room == 9){room = 10; player_x = 256; player_y = 188; cameraX = -320; cameraY = -0; cameraXMin = -320; cameraYMin = -400;}
 else if((tft.solid[i].spritecol == stairsl6) && room == 10){room = 9; player_x = 272; player_y = 80; cameraX = -80; cameraY = -0;  cameraYMin = -240; cameraXMin = -80;}
 else if((tft.solid[i].spritecol == cave5) && room == 8){room = 11; player_x = 160; player_y = 188; cameraX = -128; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit6) && room == 11){room = 8; player_x = 160; player_y = 140; cameraX = -32; cameraY = -783;  cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave6) && room == 8){room = 12; player_x = 224; player_y = 188; cameraX = -192; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit7) && room == 12){room = 8; player_x = 128; player_y = 124; cameraX = -560; cameraY = -736;  cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave7) && room == 8){room = 13; player_x = 208; player_y = 188; cameraX = -16; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}  ///////fix room cant see back wall for the registers
 else if((tft.solid[i].spritecol == exit8) && room == 13){room = 8; player_x = 161; player_y = 132; cameraX = -624; cameraY = -768;  cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave8) && room == 8){room = 14; player_x = 160; player_y = 188; cameraX = -160; cameraY = -240; cameraYMin = -240; cameraXMin = -160;} 
 else if((tft.solid[i].spritecol == exit9) && room == 14){room = 8; player_x = 112; player_y = 140; cameraX = -0; cameraY = -422;  cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave9) && room == 8){room = 15; player_x = 192; player_y = 188; cameraX = -160; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit10) && room == 15){room = 8; player_x = 192; player_y = 140; cameraX = -0; cameraY = -422;  cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave10)&& room == 8){room = 16; player_x = 208; player_y = 188; cameraX = -16; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit11) && room == 16){room = 8; player_x = 160; player_y = 140; cameraX = -608; cameraY = -416; cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave11)&& room == 8){room = 17; player_x = 208; player_y = 188; cameraX = -160; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit12) && room == 17){room = 8; player_x = 128; player_y = 140; cameraX = -0; cameraY = -112;  cameraYMin = -720; cameraXMin = -640;}
 else if((tft.solid[i].spritecol == cave12)&& room == 8){room = 18; player_x = 192; player_y = 188; cameraX = -112; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit13) && room == 18){room = 8; player_x = 208; player_y = 188; cameraX = -112; cameraY = -176; cameraYMin = -720; cameraXMin = -640;}   
 else if((tft.solid[i].spritecol == stairsl7) && room == 18){room = 19; player_x = 64; player_y = 112; cameraX = -0; cameraY = -0; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == stepsleft7) && room == 19){room = 18; player_x = 255; player_y = 112; cameraX = -160; cameraY = -0; cameraYMin = -240; cameraXMin = -160;} 
 else if((tft.solid[i].spritecol == exit14) && room == 19){room = 8; player_x = 144; player_y = 188; cameraX = -208; cameraY = -32; cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave13) && room == 8){room = 19; player_x = 192; player_y = 188; cameraX = -160; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == cave14) && room == 8){room = 18; player_x = 176; player_y = 188; cameraX = -640; cameraY = -240; cameraYMin = -240; cameraXMin = -640;}
 else if((tft.solid[i].spritecol == exit15) && room == 18){room = 8; player_x = 176; player_y = 124; cameraX = -351; cameraY = -192; cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave15) && room == 8){room = 18; player_x = 192; player_y = 188; cameraX = -1120; cameraY = -240; cameraYMin = -240, cameraXMin = -1120;}
 else if((tft.solid[i].spritecol == exit16) && room == 18){room = 8; player_x = 160; player_y = 124; cameraX = -448; cameraY = -192; cameraYMin = -720; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == stairsl8) && room == 18){room = 19; player_x = 248; player_y = 100; cameraX = -640; cameraY = -0; cameraYMin = -240; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == stepsleft8) && room == 19){room = 18; player_x = 240; player_y = 92; cameraX = -1120; cameraY = -0; cameraYMin = -240, cameraXMin = -1120;}
 else if((tft.solid[i].spritecol == exit17) && room == 19){room = 8; player_x = 240; player_y = 172; cameraX = -336; cameraY = -32; cameraYMin = -720; cameraXMin = -640;}  
 else if((tft.solid[i].spritecol == cave16) && room == 8){room = 19; player_x = 192; player_y = 160; cameraX = -640; cameraY = -240; cameraYMin = -240; cameraXMin = -640;} 
 else if((tft.solid[i].spritecol == cave17)&& room == 8){room = 20; player_x = 192; player_y = 192; cameraX = -160; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit18) && room == 20){room = 8; player_x = 192; player_y = 144; cameraX = -752; cameraY = -112; cameraYMin = -720; cameraXMin = -640;} 
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
//////seitch village2
 else if((tft.solid[i].spritecol == seitch2) && room == 1){room = 21; player_x = 122; player_y = 188; cameraX = -175; cameraY = -314; cameraXMin = -238; cameraYMin = -314;}
 else if((tft.solid[i].spritecol == exit19) && room == 21){room = 1; player_x = 122; player_y = 188; cameraX = -1014; cameraY = -1136; cameraXMin = -2080; cameraYMin = -2144;}
 else if((tft.solid[i].spritecol == cave18) && room == 21){room = 22; player_x = 176; player_y = 188; cameraX = -16; cameraY = -240; cameraYMin = -240; cameraXMin = -160;} 
 else if((tft.solid[i].spritecol == exit20) && room == 22){room = 21; player_x = 144; player_y = 160; cameraX = -64; cameraY = -314; cameraXMin = -238; cameraYMin = -314;}
 else if((tft.solid[i].spritecol == cave19) && room == 21){room = 23; player_x = 224; player_y = 188; cameraX = -192; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit21) && room == 23){room = 21; player_x = 68; player_y = 192; cameraX = -0; cameraY = -218; cameraXMin = -238; cameraYMin = -314;} 
 else if((tft.solid[i].spritecol == cave20) && room == 21){room = 24; player_x = 208; player_y = 188; cameraX = -16; cameraY = -240; cameraYMin = -240; cameraXMin = -160;} 
 else if((tft.solid[i].spritecol == exit22) && room == 24){room = 21; player_x = 208; player_y = 196; cameraX = -272; cameraY = -254; cameraXMin = -238; cameraYMin = -314;}  
 else if((tft.solid[i].spritecol == cave21) && room == 21){room = 25; player_x = 224; player_y = 188; cameraX = -192; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit23) && room == 25){room = 21; player_x = 66; player_y = 168; cameraX = -0; cameraY = -21; cameraXMin = -238; cameraYMin = -314;}
 else if((tft.solid[i].spritecol == cave22) && room == 21){room = 26; player_x = 176; player_y = 188; cameraX = -192; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit24) && room == 26){room = 21; player_x = 128; player_y = 164; cameraX = -128; cameraY = -64; cameraXMin = -238; cameraYMin = -314;}
 else if((tft.solid[i].spritecol == cave23) && room == 21){room = 27; player_x = 208; player_y = 188; cameraX = -16; cameraY = -240; cameraYMin = -240; cameraXMin = -160;}
 else if((tft.solid[i].spritecol == exit25) && room == 27){room = 21; player_x = 256; player_y = 164; cameraX = -240; cameraY = -32; cameraXMin = -238; cameraYMin = -314;}
 else if((tft.solid[i].spritecol == cave24) && room == 21){room = 28;  player_x = 176; player_y = 188; cameraX = -144; cameraY =-240;  cameraYMin = -240; cameraXMin = -316;}
 else if((tft.solid[i].spritecol == exit26) && room == 28){room = 21; player_x = 176; player_y = 132; cameraX = -0; cameraY = -64; cameraXMin = -238; cameraYMin = -314;}
 else if((tft.solid[i].spritecol == stairsl9) && room == 28){room = 29;  player_x = 240; player_y = 148; cameraX = -160; cameraY = -0; cameraXMin = -160; cameraYMin = -240;} 
 else if((tft.solid[i].spritecol == stepsleft9) && room == 29){room = 28;  player_x = 256; player_y = 52; cameraX = -320; cameraY = -64; cameraXMin = -320; cameraYMin = -240;}
 else if((tft.solid[i].spritecol == exit27) && room == 29){room = 21; player_x = 208; player_y = 80; cameraX = -0; cameraY = -0; cameraXMin = -238; cameraYMin = -314;}
 else if((tft.solid[i].spritecol == cave25) && room == 21){room = 29; player_x = 208; player_y = 188; cameraX = -16; cameraY = -239; cameraYMin = -240; cameraXMin = -160;} 
 else if((tft.solid[i].spritecol == cave26) && room == 21){room = 28; player_x = 176; player_y = 188; cameraX = -729; cameraY = -240; cameraXMin = -952; cameraYMin = -240; cameraXMax = -638;}
 else if((tft.solid[i].spritecol == exit28)&& room == 28){room = 21; player_x = 112; player_y = 132; cameraX = -240; cameraY = -64; cameraYMin = -240; cameraXMin = -240; cameraYMax = -0; cameraXMax = -0;} 
 else if((tft.solid[i].spritecol == stairsl10) && room == 28){room = 29;  player_x = 48; player_y = 144; cameraX = -412; cameraY = -0; cameraXMin = -640; cameraYMin = -240; cameraXMax = -476; cameraYMax = -0;}
 else if((tft.solid[i].spritecol == stepsleft10) && room == 29){room = 28;  player_x = 256; player_y = 52; cameraX = -952; cameraY = -64; cameraXMin = -952; cameraYMin = -240; cameraYMax = -0; cameraXMax = -638;} 
 else if((tft.solid[i].spritecol == exit29) && room == 29){room = 21; player_x = 68; player_y = 88; cameraX = -240; cameraY = -0; cameraXMin = -340; cameraYMin = -314; cameraYMax = -0; cameraXMax = -0;}
 else if((tft.solid[i].spritecol == cave27) && room == 21){room = 28; player_x = 176; player_y = 188; cameraX = -728; cameraY = -236; cameraXMin = -952; cameraYMin = -240; cameraXMax = -638;}
 else if(tft.solid[i].spritecol == register1)return true;
 else if(tft.solid[i].spritecol == register2)return true;
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
       }
   }
   //tft.updatePopup();
   return false; // Return false if don't touch anything
  };

#endif
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
 
Last edited:
ok I'm actually having buffer problems. I fixed the above problem using a foraward declaration after someone sent me link. So now my sketch is working kind of. How best to explain this???

ok here is my draw battle function.....
Code:
 void drawbattle(int16_t player_x, int16_t player_y) {

//////////////////////////////////////////////////////////////////////////////
///////////////////////////////Palette////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
 palette[0] = 0;
       palette[1] = BLACK;
             palette[2] = BLUE;
                   palette[3] = BROWN;
                         palette[4] = DARKGREEN;
                              palette[5] = GREY;
                                    palette[6] = PINK;
                                          palette[7] = RED;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////                                                
                                           palette[8] = BEIGE;
                                     palette[9] = GREEN;
                               palette[a]= DARKGREY;
                         palette[b] = LIGHTGREY;
                   palette[c] = YELLOW; 
             palette[d] = PURPLE; 
       palette[e] = WHITE;
 palette[f] = ORANGE;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
 if(count == 0)
{
x = random(0,320);
y = random(0,240);
count = 1;
}

Rect rectA {x,y,16,16};
Rect rectB {player_x, player_y,16,16};

if(tft.collideRectRect( rectA.x, rectA.y, rectA.width, rectA.height, rectB.x, rectB.y, rectB.width, rectB.height))
{
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
  tft.fillScreen(BLACK);
  tft.fillRect(0, 80, 320, 50, WHITE);  ////// draws a back grounds stripe for the monsters to sit on the length nof the screen
  tft.writeRectNBPP(143, 100, 34, 24, 4, cavespider, palette);
  tft.drawRoundRect(40, 180, 240, 40, 4, WHITE);
  tft.fillRoundRect(41, 181, 237, 37, 4, BLUE);
  tft.setCursor(90,192);
  tft.setTextColor(WHITE); 
  tft.setTextSize(2);
  tft.println("cave spider");
 
//     tft.updateScreen(); 
}
};

#endif

With the updateScreen(); function inside the drawbattle function causes the drawbattle screen to start but it flashes back and fourth between the world screen and the battle screen. But if I remove the update screen function it pops up behind the world screen and I can only see like an edge of it on a screen edge.

Should I put the updateScreen function after my drawplayer and draw battle functions in my void loop?

Edit:::::

never mind putting the update screen at the endof my loop and removing it from every where else did the trick.
 
Last edited:
ok ive been trying to learn more c++ so I can try to figure things out on my own but I'm stuck on what to do with this problem...........

ive instituted the code above for using tilemaps over 256 by 256 and that's not a problem. the problem is I'm using over 256 sprites now for the tilemap and I'm getting these errors....

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

In file included from C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\Player.h:4:0,

                 from C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\Battle.h:4,

                 from C:\Users\Duhjoker\Desktop\Dune\Dune.ino:9:

C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\world.h:7764:179: error: narrowing conversion of '258' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

 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, 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, 0, 0, 0, 0, 0, 0, 0, 0};

                                                                                                                                                                                   ^

C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\world.h:7764:179: error: narrowing conversion of '259' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\world.h:7764:179: error: narrowing conversion of '256' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\world.h:7764:179: error: narrowing conversion of '260' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\world.h:7764:179: error: narrowing conversion of '257' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]



Multiple libraries were found for "Bounce.h"
 Used: C:\Users\Duhjoker\Documents\Arduino\libraries\Bounce
 Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Bounce
Error compiling for board Teensy 3.6.

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

ive tried changing to const int but that lead me to following circles then took up 50% of the storage. should I be using const uint_16 before each bitmap name and bits? Ive actually gotten rid of a bunch of bitmaps, the main characters don't need to be added til used. I'm going with npcs have no movement unless its a cut scene. that relieved a lot of space.
 
I'm not seeing the code behind the error :: C:\Users\Duhjoker\AppData\Local\Temp\arduino_build_227155\sketch\world.h:7764:179.

That is a huge file at over 7764 lines. Pasting a couple lines in that area before and after with a note on the affected line might allow direct assessment of the issue rather than speculation. I assume the code has an array of 'sprite names'/pointers/indicators. That array type needs to be uint16_t not BYTE. Nothing should every be 'int' unless you just want a signed 32 bit number, or a temp counter and don't want to type more.
 
The problem is im using 260 bitmaps in my spritesheet. And its telling me it cant process the last 4 under byte since a byte is 256. So im trying to figure out the best and correct way to be able to use more than 256 (or 257 if you count 0) sprites in my sprite sheet.

The fix from earlier allows larger than 256 x 256 tile maps but not more than 256 tiles

Like you said its a long file so i dont really know which parts you need to see. Im having peoblems with github but will post any thing you need to see as soon as i get up.
 
Compiler error noted points to a line by number. Find that line and post it, and perhaps the line before and after.
 
All right the lines in question belong in the last tilemap call........

Code:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const byte seitch2r910a[] = {
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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 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, 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

here is the link to the repository

https://github.com/Duhjoker/Dune_game
 
Last edited:
Just this:

const uint16_t seitch2r910a[] = { ... , 0, 259, 0, ...

That array can hold any number of items - but the value of each item as BYTE ( uint8_t ) can only be 0-255.

Declaring it as uint16_t will let it hold any value 0-65535. Any place that uses those stored values will need the same change.

Also FYI - now that it is on github you can share a link to a line of code in the file by clicking the line number and taking it from the address bar: https://github.com/Duhjoker/Dune_game/blob/master/World.h#L7764
 
ok before I start running in circles trying to correct every thing, I would like to ask for a clarification......

if I change
Code:
const byte tilemap[] = {

to
Code:
const uint16_t tilemap[] = {

I will then need to go into my library and find the tilemap functions and change the uint8_t to uint16_t like so.....

Code:
void        drawTilemap(int x, int y, const uint16_t *tilemap, const uint8_t **spritesheet, const uint16_t * palette);
void        drawTilemap(int x, int y, const uint16_t *tilemap, const uint8_t **spritesheet, uint16_t dx, uint16_t dy, uint16_t dw, uint16_t dh, const uint16_t * palette);
 
Status
Not open for further replies.
Back
Top