#include #include #include #include "walks.h" static int thisCell = 0; static int walking = 0; static int youX = 0; static int youY = 180; static byte pressed = 0; void setup() { Serial.begin(9600); GD.begin(); LOAD_ASSETS(); } void loop() { GD.get_inputs(); GD.ClearColorRGB(0x000050); GD.Clear(); drawScene(); detectInput(); //swap GD.swap(); } void detectInput() { //input if (GD.inputs.tag == 200) { walking = 1; //right } else if (GD.inputs.tag == 201) { walking = 2; //left } else { walking = 0; } } void debugger() { Serial.print("x: "); Serial.print(youX); Serial.print("cell: "); Serial.println(thisCell); } void drawScene() { //draw GD.Begin(BITMAPS); if (walking == 1) { if (youX < 478) { thisCell++; if (thisCell > WALKS_CELLS) { thisCell = 0; } GD.Vertex2ii(youX, youY, WALKS_HANDLE, thisCell); youX++; debugger(); } } else if (GD.inputs.tag == 201) { if (youX > 2) { GD.cmd_translate(F16(16), F16(0)); GD.cmd_scale(F16(-1), F16(1)); GD.cmd_translate(F16(-16), F16(0)); GD.cmd_setmatrix(); thisCell++; if (thisCell > WALKS_CELLS) { thisCell = 0; } GD.Vertex2ii(youX, youY, WALKS_HANDLE, thisCell); youX--; debugger(); } } else { GD.Vertex2ii(youX, youY, WALKS_HANDLE, 0); } //GD.RestoreContext(); //controller GD.Begin(POINTS); GD.PointSize(16 * 30); GD.ColorA(96); GD.ColorRGB(160,255,160); GD.Tag(200); GD.Vertex2ii(380,160); GD.ColorRGB(255,160,160); GD.Tag(201); GD.Vertex2ii(450,160); }