My_settings.h, change PROJ_HIRES to 0
Then full rebuild
My_settings.h, change PROJ_HIRES to 0
Then full rebuild
I did so, but unfortunately it changes nothing.
As i said, iĀ“m just a beginner and i donĀ“t understand whatĀ“s going wrong. I can just try what you say.
Thanks @jonne for helping
I think you will find its because the project is still pointing to My_settings.h under the āHelloWorldā library.
I have your Pong-game running very nicely now. Can we add it to project examples?
Hereās a link for a working project copy of PokittoLib and your Pong game so you see how it is set up:
www.pokitto.com/public_html/utils/PokittoLib.zip
The things I did:
Of course you can use it for the examples! (Have you checked the settings-screen? )
Here is a improved version, it was really to fast:
#include "pokitto.h"
#include "textures.h"
Pokitto::Core game;
void scorepoint(bool voidreset);
void endgame(bool voidreset2);
char status = 0; //0=main-menu, 1=game, 2=settings, 3=about
char cursor = 0;
bool showdifficulty = 0;
bool showballmovement = 0;
char ballcolor = 0; //0=default(changing), 1=orange, 2= yellow, 3= blue, 4=gray
char difficultysetting = 60;
float padplayer = 34;
float padcom = 34;
float ballx = 52;
float bally = 41;
float movex = 0;
float movey = 0;
short scoreplayer = 0;
short scorecom = 0;
char screenW = 110;
char screenH = 88;
char movecom = 0;
char moveplayer = 0;
short difficulty = 60;
bool gamestart = 0;
bool win = 0;
int main ()
{
game.begin();
game.display.width = screenW;
game.display.height = screenH;
game.display.load565Palette(default36);
game.display.setFont(font5x7);
game.setFrameRate(60);
while (game.isRunning())
{
if (game.update())
{
/*
=====================MAINMENU======================
*/
if (status == 0)
{
//______________LOGIC/CONTROL_______________
if (cursor == 0)
{
cursor = 30;
}
if (game.buttons.pressed(BTN_DOWN) && (cursor < 50))
{
cursor += 10;
}
if (game.buttons.pressed(BTN_UP) && (cursor > 30))
{
cursor -= 10;
}
if (game.buttons.released(BTN_A))
{
status = ((cursor / 10) - 2);
cursor = 0;
endgame(1);
}
//_________________DISPLAY__________________
game.display.drawBitmap(0,0,title);
game.display.setCursor(20,30);
game.display.print("Play");
game.display.setCursor(20,40);
game.display.print("Settings");
game.display.setCursor(20,50);
game.display.print("About");
game.display.setCursor(90,80);
game.display.print("1.1");
game.display.setCursor(10,cursor);
game.display.print(">");
}
/*
=====================SETTINGS==========================
*/
if (status == 2)
{
//__________________LOGIC/CONTROL____________________
if (cursor == 0)
{
cursor = 20;
}
if (game.buttons.pressed(BTN_DOWN) && (cursor < 60))
{
if (cursor == 20) cursor += 20;
else cursor += 10;
}
if (game.buttons.pressed(BTN_UP) && (cursor > 20))
{
if (cursor == 40) cursor -= 20;
else cursor -= 10;
}
if (game.buttons.pressed(BTN_B))
{
status = 0;
cursor = 0;
}
if (game.buttons.pressed(BTN_LEFT))
{
if (cursor == 20 && ballcolor > 0) ballcolor -= 1;
if (cursor == 40) showballmovement = 0;
if (cursor == 50) showdifficulty = 0;
if (cursor == 60 && difficultysetting < 80) difficultysetting += 10;
}
if (game.buttons.pressed(BTN_RIGHT))
{
if (cursor == 20 && ballcolor < 4) ballcolor += 1;
if (cursor == 40) showballmovement = 1;
if (cursor == 50) showdifficulty = 1;
if (cursor == 60 && difficultysetting > 40) difficultysetting -= 10;
}
//_________________DISPLAY___________________
game.display.setCursor(1,1);
game.display.print("SETTINGS:");
game.display.setCursor(15,20);
game.display.print("Ball: ");
if (ballcolor == 0)
{
game.display.drawBitmap(50,21,ballgreen);
game.display.drawBitmap(58,21,ballred);
}
if (ballcolor == 1) game.display.drawBitmap(50,21,ballorange);
if (ballcolor == 2) game.display.drawBitmap(50,21,ballyellow);
if (ballcolor == 3) game.display.drawBitmap(50,21,ballblue);
if (ballcolor == 4) game.display.drawBitmap(50,21,ballgray);
game.display.setCursor(15,40);
game.display.print("shwBllMvmnt: ");
if (showballmovement == 0) game.display.print("off");
if (showballmovement == 1) game.display.print("on");
game.display.setCursor(15,50);
game.display.print("shwDffclty: ");
if (showdifficulty == 0) game.display.print("off");
if (showdifficulty == 1) game.display.print("on");
game.display.setCursor(15,60);
game.display.print("strtDffclty: ");
if (difficultysetting == 80) game.display.print("--");
if (difficultysetting == 70) game.display.print("-");
if (difficultysetting == 60) game.display.print("0");
if (difficultysetting == 50) game.display.print("+");
if (difficultysetting == 40) game.display.print("++");
game.display.drawBitmap(2,76,backarrow);
game.display.setCursor(5,cursor);
game.display.print(">");
}
/*
=========================ABOUT=========================
*/
if (status == 3)
{
//________________LOGIC/CONTROL___________________
if (game.buttons.pressed(BTN_B))
{
status = 0;
cursor = 0;
}
//____________________DISPLAY_____________________
game.display.drawBitmap(2,2,paddlegreen);
game.display.drawBitmap(13,2,paddlered);
game.display.drawBitmap(24,2,ballgreen);
game.display.drawBitmap(35,2,ballred);
game.display.drawBitmap(46,2,ballorange);
game.display.drawBitmap(57,2,ballyellow);
game.display.drawBitmap(68,2,ballblue);
game.display.drawBitmap(79,2,ballgray);
game.display.setCursor(5,55);
game.display.print("By: Zuzu36");
game.display.setCursor(5,65);
game.display.print("Made for Pokitto");
game.display.drawBitmap(2,76,backarrow);
}
/*
=========================GAME==========================
*/
if (status == 1)
{
//_________________CONTROL___________________
if (game.buttons.repeat(BTN_UP,0) && (padplayer > 0) && (gamestart == 1))
{
padplayer -= 1;
moveplayer = -1;
}
else moveplayer = 0;
if (game.buttons.repeat(BTN_DOWN,0) && (padplayer < 67) && (gamestart == 1))
{
padplayer += 1;
moveplayer = 1;
}
else moveplayer = 0;
if (game.buttons.pressed(BTN_A) && (gamestart == 0))
{
if (win == 0)
{
movex = 0.5;
}
if (win == 1)
{
movex = -0.5;
}
gamestart = 1;
}
if (game.buttons.held(BTN_C,15))
{
status = 0;
endgame(1);
}
//_________________LOGIC______________________
if ((movecom > -0.5) && (movecom < 0.5))
{
movecom = random(1,1);
}
if ((difficulty == 10)||(difficulty == 100))
{
endgame(1);
}
else difficulty = (difficultysetting - ((scoreplayer - scorecom)*2));
//*******************GAMESTART****************
if (gamestart == 1)
{
ballx += movex;
bally += movey;
padcom += movecom;
if (movey == 0)
{
movey = random(1,1);
}
//-----------------BALL------------------
if ((ballx - 1 <= 6) && ((bally + 6 >= padplayer) && (bally <= padplayer + 20)))
{
movex = 1;
movey += ((moveplayer / 2)+((bally - padplayer) / 20));
}
if ((ballx + 7 >= screenW - 6) && ((bally + 6>= padcom) && (bally <= padcom + 20)))
{
movex = -1;
movey += ((movecom / 4)+((bally -padcom) / 20));
}
if ((bally <= 0) || (bally + 6 >= 88))
{
movey *= -1;
}
//----------------SCORE-------------------
if (ballx <= 0)
{
scorecom += 1;
win = 0;
scorepoint(1);
}
if (ballx + 6 >= screenW)
{
scoreplayer += 1;
win = 1;
scorepoint(1);
}
if ((scoreplayer == 100) || (scorecom == 100))
{
endgame(1);
}
//-------------------COM------------------
if ((ballx > difficulty) && (movex > 0))
{
if (bally < padcom && padcom > 1)
{
movecom = -1;
}
if (bally + 6 > padcom + 20 && padcom + 20 < 87)
{
movecom = 1;
}
}
if (padcom - 1 <= 0)
{
movecom = 1;
}
if (padcom + 21 >= 86)
{
movecom = -1;
}
}
else
{
game.display.setCursor(30,26);
game.display.print("Ready?");
game.display.drawBitmap(70,24,btna);
}
//_____________DRAW/PRINT/COLOR_______________
if (showdifficulty == 1)
{
game.display.setCursor(1,81);
game.display.print(difficulty);
}
if (showballmovement == 1)
{
game.display.setCursor(1,1);
game.display.print(movey);
}
if (scoreplayer < 10) game.display.setCursor(43,5);
else game.display.setCursor(37,5);
game.display.print(scoreplayer);
game.display.print(" - ");
game.display.print(scorecom);
game.display.drawBitmap(0,padplayer,paddlegreen);
game.display.drawBitmap(screenW - 6,padcom,paddlered);
if ((ballcolor == 0) && ((movex < 0) || ((win == 1) && (gamestart == 0)))) game.display.drawBitmap(ballx,bally,ballred);
if ((ballcolor == 0) && ((movex > 0) || ((win == 0) && (gamestart == 0)))) game.display.drawBitmap(ballx,bally,ballgreen);
if (ballcolor == 1) game.display.drawBitmap(ballx,bally,ballorange);
if (ballcolor == 2) game.display.drawBitmap(ballx,bally,ballyellow);
if (ballcolor == 3) game.display.drawBitmap(ballx,bally,ballblue);
if (ballcolor == 4) game.display.drawBitmap(ballx,bally,ballgray);
}
game.display.bgcolor = 14;
game.display.color = 15;
}
}
return 1;
}
void scorepoint(bool voidreset)
{
padplayer = 34;
padcom = 34;
ballx = 52;
bally = 44;
movex = 0;
movey = 0;
gamestart = 0;
movecom = 0;
moveplayer = 0;
}
void endgame(bool voidreset2)
{
padplayer = 34;
padcom = 34;
ballx = 52;
bally = 44;
movex = 0;
movey = 0;
scoreplayer = 0;
scorecom = 0;
gamestart = 0;
win = 0;
movecom = 0;
moveplayer = 0;
difficulty = 60;
}
First it wasĀ“nt working. Then I created a new project with the latest version of the lib. It works!
It seems that Pokitto/POKITTO_LIBS/Physics/Shape.h is using āPokittoApp.hā --> this file doesĀ“nt exists. ItĀ“s not causing an error, but I just want to say it. ItĀ“s possibly that more files using this, I haveĀ“nt checked this.
I think that probably should be an error.
@jonne CodeBlocks also shows an not existing āPOKITTO_APPā folder. Was it in first versions of the simulator?
There was such a thing, but was removed. May be replaced in the future.
It was a wrapper that made certain things even easier to code - but - was not complete.
Iām trying to do the windows simulation with CodeBlocks. Getting errors for inline variables in pokitto_settings.h. Tried deleting the inlines and get different errors. e.g. undefined reference to `Pokitto::Display::drawColumn(int, int, int)ā I didnāt see these functions. Completely new to this, any help would be appreciated, thanks.
We moved PokittoLib to C++17. I will try to tell you how to mod the CodeBlocks options as soon as I get a moment of time
@dwidel , sorry for late reply
I will update the info on Code::Blocks and PokittoSim as soon as I can
Meanwhile, use this PokittoLib commit from earlier (mid february) before C++17 change was made. It will allow you to compile.
Thanks. I am compiling now.
Hi, I was encountering the same issues with EmBitz (targetting pokitto bins) in terms of the C++17 support and the inline variables. I pinged @Pharap and they suggested that I update the arm-gcc thatās within EmBitz.
I downloaded the latest and dropped it in, and this resolved the inline variable errors. The code is able to compile, however now fails at the linking stage with the errors @dwidel mentions above - the undefined references. From what I can see, this isnāt a compiler issue.
Looking at the codebase, it appears that all of these functions have signatures in PokittoDisplay.h, but no implementations in PokittoDisplay.cpp. Whatās more, the references are turning up as a result of calls within other PokittoDisplay.cpp implementations themselves. For example, attempting to link Pixonia gives errors within Display::drawBitMapData from the following undefined references:
undefined reference to `Pokitto::Display::drawBitmapData2BPP(int, int, int, int, unsigned char const*)'
undefined reference to `Pokitto::Display::drawBitmapData4BPP(int, int, int, int, unsigned char const*)'
undefined reference to `Pokitto::Display::drawBitmapData8BPP(int, int, int, int, unsigned char const*)'
And so on for the āXFlippedā versions of those. Other projects turn up other errors, such as a removed implementation for Display::bufferChar(int16_t, int16_t, uint16_t). Crabator turns up a distinct compiler error that seems to be a conflict of a typedef within the project and with the compiler itself:
error: reference to 'byte' is ambiguous
note: candidates are: 'enum class std::byte'
note: 'typedef uint8_t byte'
So Iām left with a few questions:
Finally, Iām very much an outsider looking in - so perhaps Iāve missed a critical step early in the process (should I not be pulling the master branch? is there a āstableā branch somewhere that gets merged to?). Please let me know if one of my core assumptions appears to be wrong. In particular, if the maintainers are able to build all targets, please say so!
To-date Iāve been using an older version of PokittoLib because it still compiles and runs fine, even with the arm-gcc that I downloaded as part of this process. But I would certainly prefer to update, assuming that the latest library has performance improvements and bugfixes (e.g., I wasted a week and a half coming to the conclusion that āfopenā has a memory leakā¦ maybe thatās fixed in the latest?).
Hi
Thanks for this. I am working on it at the moment, I hope to write up compiling with EmBitz soon.
Jonne
Looks like your project is missing some files. The interface of Pokitto::Display is stable, but the implementations themselves were reorganized to reduce the amount of #ifdef
s that were scattered around.
Can you check if PokittoFramebuffer.cpp is included?
Itās a known issue. My recommendation is to not use fopen at all.
See this wiki.
Can you check if PokittoFramebuffer.cpp is included?
Thanks. It was not, and including it made the difference. Worth noting that I had opened the project file directly from the repo; is EmBitz no longer the preferred IDE?
No. @Fmanga has made a completely new IDE for us
Its called FemtoIDE and can do C++, Java and uPython
Go to Pokitto.github.io (wip)
Aha! Thanks, Iāll take a look.