Tue Oct 11, 2016 8:49 am
Thu Oct 13, 2016 12:10 am
Tue Oct 25, 2016 10:02 pm
Fri Jul 21, 2017 11:12 pm
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; cameraX = 170; cameraY = 110;} //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; cameraX = 170; cameraY = 110;} //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; cameraX = 170; cameraY = 110;} //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; cameraX = 170; cameraY = 110;} //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.
/*This is the Main function file for the GameR-Iot Multiple MCU Arduino driven
* game system and DIY console. This is a demo game RPG set in the Dune Universe
* created by Frank Herbert.
*/
#include <GrafxT3.h>
#include <SPIN.h>
#include "SPI.h"
#include <Bounce.h>
#include "Player.h"
#include "World.h"
#include "Monsters.h"
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 7
#define TFT_SCK 13
#define TFT_MISO 12
#define TFT_MOSI 11
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
uint8_t use_fb = 1;
uint8_t use_clip_rect = 0;
uint8_t use_set_origin = 0;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
GrafxT3 tft = GrafxT3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO, &SPIN);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int player_x = 240;
int player_y = 320;
int player_direction = 2;
int x=-0,y=0;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Camera offset
int cameraX = -160; /////starting position X 0f camera on tilemap
int cameraY = -120; /////starting position Y of camera on tilemap
// Camera speed in pixels per update
int cameraXSpeed = 3;
int cameraYSpeed = 3;
// Camera offset boundaries
const int cameraXMin = -2080;
const int cameraXMax = 0;
const int cameraYMin = -2144;
const int cameraYMax = 0;
// Player offset boundaries
const int playerXMin = 80;
const int playerXMax = 240;
const int playerYMin = 80;
const int playerYMax = 160;
int animTransition;
int room = 1;
int co_ords = 1;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////Pixel Color Includes////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
uint16_t palette[16]; // Should probably be 256, but I don't use many colors...
uint16_t pixel_data[2500];
//Extra integers for color palette
int a = 0xa; int b = 0xb; int c = 0xc;
int d = 0xd; int e = 0xe; int f = 0xf;
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////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
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////Set-up//////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void setup() {
while (!Serial && (millis() < 4000)) ;
Serial.begin(115200);
tft.begin();
tft.setRotation(1);
tft.fillScreen(BLACK);
//tft.setFrameRate(60);
tft.persistence = false;
pinMode(buttonUp, INPUT_PULLUP);
pinMode(buttonDown, INPUT_PULLUP);
pinMode(buttonLeft, INPUT_PULLUP);
pinMode(buttonRight, INPUT_PULLUP);
pinMode(buttonS, INPUT_PULLUP);
pinMode(buttonX, INPUT_PULLUP);
pinMode(buttonY, INPUT_PULLUP);
pinMode(buttonA, INPUT_PULLUP);
pinMode(buttonB, INPUT_PULLUP);
pinMode(buttonT, INPUT_PULLUP);
tft.useFrameBuffer(use_fb);
uint32_t start_time = millis();
// use_fb = !use_fb;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////Loop////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void loop(void) {
//updates the GameRIot (the display, the sound, the buttons, everyyhing)
//returns true when it's time to render a new frame (20 times/second)
// if(tft.updateAll()){
///////////////////////////////////////////////////////////////////////////////
////////////////////////////////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] = LIGHTBROWN;
palette[9] = GREEN;
palette[a]= DARKGREY;
palette[b] = LIGHTGREY;
palette[c] = YELLOW;
palette[d] = PURPLE;
palette[e] = WHITE;
palette[f] = NAVY;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////Tilemap/////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
if(room == 1){
tft.drawTilemap(cameraX, cameraY, dune_demo, spritesheet, palette);}
if(room == 2){
tft.drawTilemap(cameraX = 0, cameraY = 0, room1, spritesheet, palette);}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////Buttons/////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
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 -= 3;
if(checkcolision())
{
player_y += 3;}
}
if(player_y <= 32){
player_y = 32;}
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////Down///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (ButtonDown.fallingEdge()){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulfrontw,palette);
player_direction = 2;
player_y += 3;
if(checkcolision())
{
player_y -=3;}
}
if(player_y >= 216){
player_y = 216;}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////Left////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (ButtonLeft.fallingEdge()){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulleftw,palette);
player_direction = 3;
player_x -= 3;
if(checkcolision())
{
player_x += 3;}
}
if(player_x >= 288){
player_x = 288;}
//////////////////////////////////////////////////////////////////////////////
////////////////////////////Right////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (ButtonRight.fallingEdge()){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulrightw,palette);
player_direction = 4;
player_x += 3;
if(checkcolision())
{
player_x -= 3;}
}
if(player_x <= 32){
player_x = 32;}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////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.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 == rock){tft.popup(F(" ""Rock"" "),1); return true;} //Return True if character have touched the wall//return true;
else if(tft.solid[i].spritecol == cave) && room == 1) {room = 2; player_x = 32; player_y = 204; cameraX = 170; cameraY = 110;} //return true;
else if(tft.solid[i].spritecol == rockbl)return true;
else if(tft.solid[i].spritecol == rockbr)return true;
else if(tft.solid[i].spritecol == rocktl)return true;
else if(tft.solid[i].spritecol == rocktr)return true;
else if(tft.solid[i].spritecol == seitch) return true;
else if(tft.solid[i].spritecol == stairsl) return true;
else if(tft.solid[i].spritecol == stairsr) return true;
}
}
return false; // Return false if don't touch anything
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////