This is my first attempt to use the simulator. It displays a bouncing line.
Hold down the A button (Z on the keyboard) to clear the screen before each line draw.

To build it, replace the code in “Hello.c” with this code:
#include "Pokitto.h"
Pokitto::Core game;
/*
In this tutorial we are using fast screen mode.
It means screen resolution is 110x88
*/
//setting variables
// x coordinates for each point
int16_t x[2];
// y coordinates for each point
int16_t y[2];
// x velocities (added to x each frame)
int16_t xv[2] = {2,2};
// y velocities (added to y each frame)
int16_t yv[2] = {2,2};
// index
int16_t i;
// color to make the line
uint16_t color = 1;
char screenW = 110;
char screenH = 88;
int main(){
game.begin();
game.display.width = screenW;
game.display.height = screenH;
game.setFrameRate(60);
game.display.persistence = 1 ;
for(i= 0 ; i < 2; i++)
{
x[i] = random( screenW - 1); // randomly position the points
y[i] = random(screenH -1);
}
while (game.isRunning()) {
if (game.update()) {
//-----------buttons-------------
if (game.buttons.repeat(BTN_A,0)){ //if button a is pressed
game.display.persistence = 0 ;; //then turn off persistence (clear the screen each frame)
}
else {
game.display.persistence = 1 ; // don't cleat the screen each frame
}
//----------logic----------
// move the points
for(i= 0 ; i < 2; i++)
{
x[i] = x[i] + xv[i]; // the the x velocity to the x points
if ((x[i] >= screenW) || (x[i] < 0)) // if the point is off the screen
{
xv[i] = - xv[i]; // reverse the velocity
x[i] = x[i] + xv[i]; // and undo the move
}
y[i] = y[i] + yv[i]; // the the x velocity to the x point
if ((y[i] >= screenH) || (y[i] < 0)) // if the point is off the screen
{
yv[i] = - yv[i]; // reverse the velocity
y[i] = y[i] + yv[i]; // and undo the move
}
}
// draw
game.display.color = color/4; // change the color every 4 frames
game.display.drawLine(x[0],y[0],x[1],y[1]); // draw a line between the two invisible points
color = color + 1; // advance the color variable
if (color > 59) color = 1; // but keep it under 15 * 4
}
}
return(1);
}
Catsfolly



. Still don’t understand how to tune colors .


