A great PuzzleAction game originally by Aphrodite and Ported to Pokitto by Catsfolly
Dependencies: PokittoLib
Squiddy.cpp@3:998abe0a1900, 2018-01-05 (annotated)
- Committer:
- Pokitto
- Date:
- Fri Jan 05 02:40:34 2018 +0000
- Revision:
- 3:998abe0a1900
- Parent:
- 0:411a75fba946
PokittoLib updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pokitto | 0:411a75fba946 | 1 | #include "Pokitto.h" |
Pokitto | 0:411a75fba946 | 2 | Pokitto::Core game; |
Pokitto | 0:411a75fba946 | 3 | int width=110; |
Pokitto | 0:411a75fba946 | 4 | int height=88; |
Pokitto | 0:411a75fba946 | 5 | |
Pokitto | 0:411a75fba946 | 6 | // squiddy based on Aphrodite's Pico 8 game |
Pokitto | 0:411a75fba946 | 7 | // Pokitto port copyright 2017 Dave Akers |
Pokitto | 0:411a75fba946 | 8 | |
Pokitto | 0:411a75fba946 | 9 | extern int16_t lil_map[]; // table of all the level maps |
Pokitto | 0:411a75fba946 | 10 | extern int16_t tile_table[]; // table of colors for the map screen |
Pokitto | 0:411a75fba946 | 11 | extern uint8_t *bitmap_table[]; // table of pointers to the bitmaps for the game screen |
Pokitto | 0:411a75fba946 | 12 | extern uint8_t squiddy[]; // bitmap for squddy, the main character |
Pokitto | 0:411a75fba946 | 13 | extern uint8_t grid[]; //bimap for the grid )(used on the title screen) |
Pokitto | 0:411a75fba946 | 14 | extern uint8_t ball[]; // bitmap for the ball |
Pokitto | 0:411a75fba946 | 15 | extern uint8_t heart[]; // bitmap for the heart, used in a level description |
Pokitto | 0:411a75fba946 | 16 | extern uint8_t face[]; // bitmap for the face, used in a level descriiption |
Pokitto | 0:411a75fba946 | 17 | extern uint8_t cw[]; // bitmap for the copyright symbol |
Pokitto | 0:411a75fba946 | 18 | extern const char *msg_table[64]; // table of text messages for each level |
Pokitto | 0:411a75fba946 | 19 | #define TWOPI (3.14159265359 * 2) // 2 times pi |
Pokitto | 0:411a75fba946 | 20 | #define TILESIZE (10) // height and width of a tile |
Pokitto | 0:411a75fba946 | 21 | #define MINSX (30) // ddefine the screnn coordinate limits for squiddy |
Pokitto | 0:411a75fba946 | 22 | #define MAXSX (80) // the screen scrolls to keep squiddy in these limits |
Pokitto | 0:411a75fba946 | 23 | #define MAXSY (60) |
Pokitto | 0:411a75fba946 | 24 | #define MINSY (20) |
Pokitto | 0:411a75fba946 | 25 | // game states |
Pokitto | 0:411a75fba946 | 26 | #define S_TITLE ( 0) |
Pokitto | 0:411a75fba946 | 27 | #define S_MAP ( 1) |
Pokitto | 0:411a75fba946 | 28 | #define S_TRANSITION (2) |
Pokitto | 0:411a75fba946 | 29 | #define S_PLAY (3) |
Pokitto | 0:411a75fba946 | 30 | #define S_WON (4) |
Pokitto | 0:411a75fba946 | 31 | #define S_LOST (5) |
Pokitto | 0:411a75fba946 | 32 | |
Pokitto | 0:411a75fba946 | 33 | #define WORDSPERLEVEL (72) |
Pokitto | 0:411a75fba946 | 34 | |
Pokitto | 0:411a75fba946 | 35 | const int NUM_LEVELS = 32; |
Pokitto | 0:411a75fba946 | 36 | struct ldata{ |
Pokitto | 0:411a75fba946 | 37 | double startx; // squiddys starting x position, in number of tiles |
Pokitto | 0:411a75fba946 | 38 | double starty; // squiddys starting x position, in number of tiles |
Pokitto | 0:411a75fba946 | 39 | double startangle; // xgzfg znbld, in rotations |
Pokitto | 0:411a75fba946 | 40 | double dist; // distance in tiles between squiddy and the ball |
Pokitto | 0:411a75fba946 | 41 | double speed; // rotation speed, in rotatio9ns per second |
Pokitto | 0:411a75fba946 | 42 | float attract; // force of the magnetic attraction, in pixels per second |
Pokitto | 0:411a75fba946 | 43 | }; |
Pokitto | 0:411a75fba946 | 44 | static ldata leveldata[NUM_LEVELS] = { |
Pokitto | 0:411a75fba946 | 45 | { 7.5, 7.5, 0.5,2. , 0.5 , 30 }, // 0 |
Pokitto | 0:411a75fba946 | 46 | { 3 , 7. , 0.5,2. , 0.75, 30 }, // 1 |
Pokitto | 0:411a75fba946 | 47 | { 3 ,12 , 0.5,1.5,-0.50, 10 }, // 2 |
Pokitto | 0:411a75fba946 | 48 | { 3 ,12 , 0.5,2 , 0.75, 1 }, // 3 |
Pokitto | 0:411a75fba946 | 49 | { 2 , 2 , 0.0,1.5, 0.60, 1 }, // 4 |
Pokitto | 0:411a75fba946 | 50 | |
Pokitto | 0:411a75fba946 | 51 | { 2 , 6 , 0.25,2. , 0.6 , 10 }, // 5 |
Pokitto | 0:411a75fba946 | 52 | { 2 ,13. , 0.5 ,2. ,-0.5 , 20 }, // 6 |
Pokitto | 0:411a75fba946 | 53 | { 3 , 3 , 0.75,2 , 0.5 , 15 }, // 7 |
Pokitto | 0:411a75fba946 | 54 | { 4 ,11 , 0.25,1.5, 0.5 , 40 }, // 8 |
Pokitto | 0:411a75fba946 | 55 | { 2 ,13 , 0.75,2 , 0.50, 1 }, // 9 |
Pokitto | 0:411a75fba946 | 56 | |
Pokitto | 0:411a75fba946 | 57 | { 1.5,13 , 0.75,2. , 0.5 , 1 }, // 10 |
Pokitto | 0:411a75fba946 | 58 | { 4 , 2. , 0 ,1.5 , 0.5 , 1 }, // 11 |
Pokitto | 0:411a75fba946 | 59 | { 2 , 6 , 0.25,2 , 0.60, 10 }, // 12 |
Pokitto | 0:411a75fba946 | 60 | { 8 , 6.5, 0.0 ,3 ,-0.30, 1 }, // 13 sb 9.5, 7.5 |
Pokitto | 0:411a75fba946 | 61 | { 2 , 2 , 0.0 ,2 , 0.30, 10 }, // 14 |
Pokitto | 0:411a75fba946 | 62 | |
Pokitto | 0:411a75fba946 | 63 | { 2 , 2. , 0 ,2. , 0.3 , 5 }, // 15 |
Pokitto | 0:411a75fba946 | 64 | { 4 , 5. , 0 ,2. , 0.3 , 1 }, // 16 |
Pokitto | 0:411a75fba946 | 65 | {11.5, 3.5, 0 ,1.5 , 0.60, 20 }, // 17 |
Pokitto | 0:411a75fba946 | 66 | { 5.5, 2.5, 0.0 ,1.5 , 0.60, 20 }, // 18 |
Pokitto | 0:411a75fba946 | 67 | { 1.5, 1.5, 0.0 ,1.5 ,-0.40, 20 }, // 19 |
Pokitto | 0:411a75fba946 | 68 | |
Pokitto | 0:411a75fba946 | 69 | { 4 , 2 , 0. ,1.5 ,-0.5 , 5 }, // 20 |
Pokitto | 0:411a75fba946 | 70 | { 2 , 6. , 0 ,1.5 ,-0.5 ,-10 }, // 21 |
Pokitto | 0:411a75fba946 | 71 | { 3 , 4 , 0.0 ,1.5 ,-0.50, 10 }, // 22 |
Pokitto | 0:411a75fba946 | 72 | { 7.5, 7.5, 0.0 ,2.5 ,-0.50, 20 }, // 23 |
Pokitto | 0:411a75fba946 | 73 | { 1 , 6.5, 0.5 ,1.5 , 0.50, 10 }, // 24 y was 7.5 |
Pokitto | 0:411a75fba946 | 74 | |
Pokitto | 0:411a75fba946 | 75 | { 7.5, 2.5, 0 ,1.4 ,-1.5 , 20 }, // 25 |
Pokitto | 0:411a75fba946 | 76 | { 3 , 5. , 0 ,1.5 ,-0.5 , 12 }, // 26 |
Pokitto | 0:411a75fba946 | 77 | { 3 , 5. , 0 ,3. ,-0.50, 10 }, // 27 |
Pokitto | 0:411a75fba946 | 78 | { 7.5,11. , 0.0 ,1.5 ,-0.50, 10 }, // 28 |
Pokitto | 0:411a75fba946 | 79 | { 1.5,13.5, 0.0 ,1.5 ,-0.50, 10 }, // 29 |
Pokitto | 0:411a75fba946 | 80 | |
Pokitto | 0:411a75fba946 | 81 | { 1 , 1 , 0 ,1.5 ,-0.33, 0 }, // 30 |
Pokitto | 0:411a75fba946 | 82 | { 7.5, 4.5, 0.25,2. , 0.6 , 10 }, // 31 |
Pokitto | 0:411a75fba946 | 83 | |
Pokitto | 0:411a75fba946 | 84 | |
Pokitto | 0:411a75fba946 | 85 | }; |
Pokitto | 0:411a75fba946 | 86 | ///////////////////////////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 87 | // |
Pokitto | 0:411a75fba946 | 88 | // Read man - return index for a given map position |
Pokitto | 0:411a75fba946 | 89 | // |
Pokitto | 0:411a75fba946 | 90 | ////////////////////////////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 91 | |
Pokitto | 0:411a75fba946 | 92 | int8_t shiftval[] = { |
Pokitto | 0:411a75fba946 | 93 | 12, 8, 4, 0, |
Pokitto | 0:411a75fba946 | 94 | 12, 8, 4, 0, |
Pokitto | 0:411a75fba946 | 95 | 12, 8, 4, 0, |
Pokitto | 0:411a75fba946 | 96 | 12, 8, 4, 0, |
Pokitto | 0:411a75fba946 | 97 | 12, 8, 4, 0 }; |
Pokitto | 0:411a75fba946 | 98 | |
Pokitto | 0:411a75fba946 | 99 | |
Pokitto | 0:411a75fba946 | 100 | int16_t read_map(int x, int y, int level) |
Pokitto | 0:411a75fba946 | 101 | { |
Pokitto | 0:411a75fba946 | 102 | int index; |
Pokitto | 0:411a75fba946 | 103 | int col; |
Pokitto | 0:411a75fba946 | 104 | uint16_t data; |
Pokitto | 0:411a75fba946 | 105 | if ((x < 0) || (y < 0)) return (0); |
Pokitto | 0:411a75fba946 | 106 | index = ((level -1) * WORDSPERLEVEL) + ((y/TILESIZE) * 4); |
Pokitto | 0:411a75fba946 | 107 | col = x/TILESIZE; |
Pokitto | 0:411a75fba946 | 108 | index += col/4; // 4 words oer row |
Pokitto | 0:411a75fba946 | 109 | data = lil_map[index]; |
Pokitto | 0:411a75fba946 | 110 | // one word has 4 nibbles of data col0col1col2ol3 |
Pokitto | 0:411a75fba946 | 111 | data = data >> shiftval[col]; |
Pokitto | 0:411a75fba946 | 112 | return (data & 0x0f); |
Pokitto | 0:411a75fba946 | 113 | } |
Pokitto | 0:411a75fba946 | 114 | //////////////////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 115 | //// |
Pokitto | 0:411a75fba946 | 116 | //// draw_world draw the workd using bitmaps |
Pokitto | 0:411a75fba946 | 117 | //// |
Pokitto | 0:411a75fba946 | 118 | //////////////////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 119 | |
Pokitto | 0:411a75fba946 | 120 | void draw_world(int xstart, int ystart, int step, int index,int aframe){ |
Pokitto | 0:411a75fba946 | 121 | int i,x,y,j; |
Pokitto | 0:411a75fba946 | 122 | uint16_t temp; |
Pokitto | 0:411a75fba946 | 123 | int color; |
Pokitto | 0:411a75fba946 | 124 | int rowstart; |
Pokitto | 0:411a75fba946 | 125 | int xfirst; |
Pokitto | 0:411a75fba946 | 126 | |
Pokitto | 0:411a75fba946 | 127 | xfirst = xstart; |
Pokitto | 0:411a75fba946 | 128 | rowstart = 0; |
Pokitto | 0:411a75fba946 | 129 | while( xfirst < (1 - step)) |
Pokitto | 0:411a75fba946 | 130 | { |
Pokitto | 0:411a75fba946 | 131 | xfirst += step; |
Pokitto | 0:411a75fba946 | 132 | rowstart++; |
Pokitto | 0:411a75fba946 | 133 | } |
Pokitto | 0:411a75fba946 | 134 | |
Pokitto | 0:411a75fba946 | 135 | y= ystart; |
Pokitto | 0:411a75fba946 | 136 | j = 0; |
Pokitto | 0:411a75fba946 | 137 | while ( y < (1-step)) |
Pokitto | 0:411a75fba946 | 138 | { |
Pokitto | 0:411a75fba946 | 139 | y = y + step; |
Pokitto | 0:411a75fba946 | 140 | j++; |
Pokitto | 0:411a75fba946 | 141 | } |
Pokitto | 0:411a75fba946 | 142 | index += j << 2; |
Pokitto | 0:411a75fba946 | 143 | for (; (y < height) && (j < 18); y+= step, j++, index += 4) |
Pokitto | 0:411a75fba946 | 144 | { |
Pokitto | 0:411a75fba946 | 145 | x = xfirst; |
Pokitto | 0:411a75fba946 | 146 | for (i = rowstart; (i < 16) && (x < width) ; i++, x += step) |
Pokitto | 0:411a75fba946 | 147 | { |
Pokitto | 0:411a75fba946 | 148 | temp = lil_map[index + (i >> 2)]; |
Pokitto | 0:411a75fba946 | 149 | color = (temp >> shiftval[i]) & 0x0f; |
Pokitto | 0:411a75fba946 | 150 | if (color > 0) |
Pokitto | 0:411a75fba946 | 151 | { |
Pokitto | 0:411a75fba946 | 152 | if (color > 3) |
Pokitto | 0:411a75fba946 | 153 | game.display.drawBitmap(x,y,bitmap_table[color] + aframe); |
Pokitto | 0:411a75fba946 | 154 | else |
Pokitto | 0:411a75fba946 | 155 | game.display.drawBitmap(x,y,bitmap_table[color]); |
Pokitto | 0:411a75fba946 | 156 | } |
Pokitto | 0:411a75fba946 | 157 | } |
Pokitto | 0:411a75fba946 | 158 | } |
Pokitto | 0:411a75fba946 | 159 | |
Pokitto | 0:411a75fba946 | 160 | } |
Pokitto | 0:411a75fba946 | 161 | |
Pokitto | 0:411a75fba946 | 162 | ////////////////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 163 | //// |
Pokitto | 0:411a75fba946 | 164 | //// draw_map - draw the world using solid colors |
Pokitto | 0:411a75fba946 | 165 | //// |
Pokitto | 0:411a75fba946 | 166 | ////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 167 | void draw_map(int xstart, int ystart, int step, int index){ |
Pokitto | 0:411a75fba946 | 168 | int i,x,y,j; |
Pokitto | 0:411a75fba946 | 169 | uint16_t temp; |
Pokitto | 0:411a75fba946 | 170 | int color_index; |
Pokitto | 0:411a75fba946 | 171 | int rowstart; |
Pokitto | 0:411a75fba946 | 172 | int xfirst; |
Pokitto | 0:411a75fba946 | 173 | |
Pokitto | 0:411a75fba946 | 174 | xfirst = xstart; |
Pokitto | 0:411a75fba946 | 175 | rowstart = 0; |
Pokitto | 0:411a75fba946 | 176 | while( xfirst < (1 - step)) |
Pokitto | 0:411a75fba946 | 177 | { |
Pokitto | 0:411a75fba946 | 178 | xfirst += step; |
Pokitto | 0:411a75fba946 | 179 | rowstart++; |
Pokitto | 0:411a75fba946 | 180 | } |
Pokitto | 0:411a75fba946 | 181 | |
Pokitto | 0:411a75fba946 | 182 | y= ystart; |
Pokitto | 0:411a75fba946 | 183 | j = 0; |
Pokitto | 0:411a75fba946 | 184 | while ( y < (1-step)) |
Pokitto | 0:411a75fba946 | 185 | { |
Pokitto | 0:411a75fba946 | 186 | y = y + step; |
Pokitto | 0:411a75fba946 | 187 | j++; |
Pokitto | 0:411a75fba946 | 188 | } |
Pokitto | 0:411a75fba946 | 189 | index += j << 2; |
Pokitto | 0:411a75fba946 | 190 | for (; (y < height) && (j < 18); y+= step, j++, index += 4) |
Pokitto | 0:411a75fba946 | 191 | { |
Pokitto | 0:411a75fba946 | 192 | x = xfirst; |
Pokitto | 0:411a75fba946 | 193 | for (i = rowstart; (i < 16) && (x < width) ; i++, x += step) |
Pokitto | 0:411a75fba946 | 194 | { |
Pokitto | 0:411a75fba946 | 195 | temp = lil_map[index + (i >> 2)]; |
Pokitto | 0:411a75fba946 | 196 | color_index = (temp >> shiftval[i]) & 0x0f; |
Pokitto | 0:411a75fba946 | 197 | if (color_index > 0) |
Pokitto | 0:411a75fba946 | 198 | { |
Pokitto | 0:411a75fba946 | 199 | game.display.color = tile_table[color_index]; |
Pokitto | 0:411a75fba946 | 200 | game.display.fillRectangle(x,y,step,step); |
Pokitto | 0:411a75fba946 | 201 | |
Pokitto | 0:411a75fba946 | 202 | } |
Pokitto | 0:411a75fba946 | 203 | } |
Pokitto | 0:411a75fba946 | 204 | } |
Pokitto | 0:411a75fba946 | 205 | |
Pokitto | 0:411a75fba946 | 206 | } |
Pokitto | 0:411a75fba946 | 207 | |
Pokitto | 0:411a75fba946 | 208 | //////////////////////////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 209 | //// |
Pokitto | 0:411a75fba946 | 210 | //// draw_textbox draw a box to write text into |
Pokitto | 0:411a75fba946 | 211 | //// |
Pokitto | 0:411a75fba946 | 212 | //////////////////////////////////////////////////////////////////////////////// |
Pokitto | 0:411a75fba946 | 213 | |
Pokitto | 0:411a75fba946 | 214 | void draw_textbox(int x, int y,int boxlen, int boxheight, int bcolor, int frameColor) |
Pokitto | 0:411a75fba946 | 215 | { |
Pokitto | 0:411a75fba946 | 216 | |
Pokitto | 0:411a75fba946 | 217 | game.display.color = bcolor; |
Pokitto | 0:411a75fba946 | 218 | game.display.fillRectangle(x-2,y-3,boxlen,boxheight); |
Pokitto | 0:411a75fba946 | 219 | game.display.color = frameColor; |
Pokitto | 0:411a75fba946 | 220 | game.display.drawRectangle(x-3,y -4,boxlen+1,boxheight+2); |
Pokitto | 0:411a75fba946 | 221 | |
Pokitto | 0:411a75fba946 | 222 | } |
Pokitto | 0:411a75fba946 | 223 | |
Pokitto | 0:411a75fba946 | 224 | |
Pokitto | 0:411a75fba946 | 225 | int main(){ |
Pokitto | 0:411a75fba946 | 226 | |
Pokitto | 0:411a75fba946 | 227 | int xworld, yworld; // screen coordinates for drawing the world |
Pokitto | 0:411a75fba946 | 228 | float ballwx, ballwy; // world coordinates of the ball |
Pokitto | 0:411a75fba946 | 229 | int ballsx, ballsy; // screen coordinates of the ball |
Pokitto | 0:411a75fba946 | 230 | float squidwx,squidwy; // world coordinates for squiddy |
Pokitto | 0:411a75fba946 | 231 | int squidsx,squidsy; // screen coordinates for squiddy |
Pokitto | 0:411a75fba946 | 232 | int release_count; // number of frames that no buttons were pushed |
Pokitto | 0:411a75fba946 | 233 | int level; // game level |
Pokitto | 0:411a75fba946 | 234 | int state, state_count; // game state |
Pokitto | 0:411a75fba946 | 235 | ldata *lptr; // pointer to current level map data |
Pokitto | 0:411a75fba946 | 236 | int dist; // distance between squiddy and the ball |
Pokitto | 0:411a75fba946 | 237 | int sx,sy; |
Pokitto | 0:411a75fba946 | 238 | int test; |
Pokitto | 0:411a75fba946 | 239 | int mag_flags; |
Pokitto | 0:411a75fba946 | 240 | int animframe; // anim frame for arrows |
Pokitto | 0:411a75fba946 | 241 | float attract; // current magnetic attraction |
Pokitto | 0:411a75fba946 | 242 | int zoomsize; // transition size |
Pokitto | 0:411a75fba946 | 243 | boolean ball_spins = true; |
Pokitto | 0:411a75fba946 | 244 | double angle, angleinc; |
Pokitto | 0:411a75fba946 | 245 | game.begin(); |
Pokitto | 0:411a75fba946 | 246 | game.display.width = width; // full size |
Pokitto | 0:411a75fba946 | 247 | game.display.height = height; |
Pokitto | 0:411a75fba946 | 248 | game.setFrameRate(20); |
Pokitto | 0:411a75fba946 | 249 | game.display.load565Palette(def565palette); |
Pokitto | 0:411a75fba946 | 250 | game.display.setFont(font5x7); |
Pokitto | 0:411a75fba946 | 251 | xworld = 0; |
Pokitto | 0:411a75fba946 | 252 | yworld = 0; |
Pokitto | 0:411a75fba946 | 253 | angle = 0.0; |
Pokitto | 0:411a75fba946 | 254 | angleinc = 0.1 ; |
Pokitto | 0:411a75fba946 | 255 | squidwx = 50; |
Pokitto | 0:411a75fba946 | 256 | squidwy = 40; |
Pokitto | 0:411a75fba946 | 257 | animframe = 0; |
Pokitto | 0:411a75fba946 | 258 | |
Pokitto | 0:411a75fba946 | 259 | level = 1; |
Pokitto | 0:411a75fba946 | 260 | state = S_TITLE; |
Pokitto | 0:411a75fba946 | 261 | state_count = 0; |
Pokitto | 0:411a75fba946 | 262 | |
Pokitto | 0:411a75fba946 | 263 | |
Pokitto | 0:411a75fba946 | 264 | while (game.isRunning()) { |
Pokitto | 0:411a75fba946 | 265 | if (game.update()) { |
Pokitto | 0:411a75fba946 | 266 | |
Pokitto | 0:411a75fba946 | 267 | #if 0 |
Pokitto | 0:411a75fba946 | 268 | // test code to scroll the screen |
Pokitto | 0:411a75fba946 | 269 | if (game.buttons.repeat(BTN_UP,0)){ |
Pokitto | 0:411a75fba946 | 270 | yworld++; |
Pokitto | 0:411a75fba946 | 271 | } |
Pokitto | 0:411a75fba946 | 272 | if (game.buttons.repeat(BTN_DOWN,0)){ |
Pokitto | 0:411a75fba946 | 273 | yworld--; |
Pokitto | 0:411a75fba946 | 274 | } |
Pokitto | 0:411a75fba946 | 275 | if (game.buttons.repeat(BTN_LEFT,0)){ |
Pokitto | 0:411a75fba946 | 276 | xworld++; |
Pokitto | 0:411a75fba946 | 277 | } |
Pokitto | 0:411a75fba946 | 278 | if (game.buttons.repeat(BTN_RIGHT,0)){ |
Pokitto | 0:411a75fba946 | 279 | xworld--; |
Pokitto | 0:411a75fba946 | 280 | } |
Pokitto | 0:411a75fba946 | 281 | #endif |
Pokitto | 0:411a75fba946 | 282 | switch(state) |
Pokitto | 0:411a75fba946 | 283 | { |
Pokitto | 0:411a75fba946 | 284 | |
Pokitto | 0:411a75fba946 | 285 | |
Pokitto | 0:411a75fba946 | 286 | //game.display.drawPixel(x,y,pixel/16); |
Pokitto | 0:411a75fba946 | 287 | |
Pokitto | 0:411a75fba946 | 288 | case S_TITLE: |
Pokitto | 0:411a75fba946 | 289 | { |
Pokitto | 0:411a75fba946 | 290 | int i,j; |
Pokitto | 0:411a75fba946 | 291 | // fill the background with the grid |
Pokitto | 0:411a75fba946 | 292 | for (i = 0 ; i < 120 ; i = i + 10) |
Pokitto | 0:411a75fba946 | 293 | { |
Pokitto | 0:411a75fba946 | 294 | for(j = 0; j < 90 ; j= j + 10) |
Pokitto | 0:411a75fba946 | 295 | { |
Pokitto | 0:411a75fba946 | 296 | game.display.drawBitmap(i,j,grid); |
Pokitto | 0:411a75fba946 | 297 | } |
Pokitto | 0:411a75fba946 | 298 | } |
Pokitto | 0:411a75fba946 | 299 | draw_textbox(10,10,12 * 6, 12, 0, C_DARKGREEN); |
Pokitto | 0:411a75fba946 | 300 | game.display.color = C_GREEN; |
Pokitto | 0:411a75fba946 | 301 | game.display.setCursor(10,10); |
Pokitto | 0:411a75fba946 | 302 | game.display.print("Aphrodite's"); |
Pokitto | 0:411a75fba946 | 303 | |
Pokitto | 0:411a75fba946 | 304 | draw_textbox(30,30,8 * 6, 12, 0, C_DARKGREEN); |
Pokitto | 0:411a75fba946 | 305 | game.display.color = C_GREEN; |
Pokitto | 0:411a75fba946 | 306 | game.display.setCursor(30,30); |
Pokitto | 0:411a75fba946 | 307 | |
Pokitto | 0:411a75fba946 | 308 | game.display.print("SQUIDDY"); |
Pokitto | 0:411a75fba946 | 309 | |
Pokitto | 0:411a75fba946 | 310 | |
Pokitto | 0:411a75fba946 | 311 | draw_textbox(20,77,11 * 6, 12, 0, C_WHITE); |
Pokitto | 0:411a75fba946 | 312 | game.display.setCursor(20,77); |
Pokitto | 0:411a75fba946 | 313 | game.display.color = C_WHITE; |
Pokitto | 0:411a75fba946 | 314 | game.display.print(" 2017 DSA"); |
Pokitto | 0:411a75fba946 | 315 | game.display.drawBitmap(20,77,cw); |
Pokitto | 0:411a75fba946 | 316 | |
Pokitto | 0:411a75fba946 | 317 | state_count++; |
Pokitto | 0:411a75fba946 | 318 | // blink the "press a" message |
Pokitto | 0:411a75fba946 | 319 | if ((state_count & 0x0f) > 3) |
Pokitto | 0:411a75fba946 | 320 | { |
Pokitto | 0:411a75fba946 | 321 | draw_textbox(30,55,7 * 6, 12, 0, 3); |
Pokitto | 0:411a75fba946 | 322 | game.display.setCursor(30,55); |
Pokitto | 0:411a75fba946 | 323 | game.display.color = C_GREEN; |
Pokitto | 0:411a75fba946 | 324 | game.display.print("PRESS A"); |
Pokitto | 0:411a75fba946 | 325 | |
Pokitto | 0:411a75fba946 | 326 | } |
Pokitto | 0:411a75fba946 | 327 | if (game.buttons.repeat(BTN_A,0)) |
Pokitto | 0:411a75fba946 | 328 | state = S_MAP; |
Pokitto | 0:411a75fba946 | 329 | release_count = 0; |
Pokitto | 0:411a75fba946 | 330 | |
Pokitto | 0:411a75fba946 | 331 | break; |
Pokitto | 0:411a75fba946 | 332 | } |
Pokitto | 0:411a75fba946 | 333 | case S_MAP: |
Pokitto | 0:411a75fba946 | 334 | { |
Pokitto | 0:411a75fba946 | 335 | game.display.color = C_WHITE; |
Pokitto | 0:411a75fba946 | 336 | game.display.setCursor(3,3); |
Pokitto | 0:411a75fba946 | 337 | // show the text message for this level |
Pokitto | 0:411a75fba946 | 338 | #if 1 |
Pokitto | 0:411a75fba946 | 339 | if (msg_table[level *2] != 0) |
Pokitto | 0:411a75fba946 | 340 | game.display.print(msg_table[level * 2]); |
Pokitto | 0:411a75fba946 | 341 | game.display.setCursor(3,12); |
Pokitto | 0:411a75fba946 | 342 | if (msg_table[(level *2) + 1] != 0) |
Pokitto | 0:411a75fba946 | 343 | game.display.print(msg_table[(level * 2) + 1]); |
Pokitto | 0:411a75fba946 | 344 | #endif |
Pokitto | 0:411a75fba946 | 345 | if (level == 9) |
Pokitto | 0:411a75fba946 | 346 | { |
Pokitto | 0:411a75fba946 | 347 | game.display.drawBitmap(16, 3,heart); |
Pokitto | 0:411a75fba946 | 348 | game.display.drawBitmap(16,12,heart); |
Pokitto | 0:411a75fba946 | 349 | } |
Pokitto | 0:411a75fba946 | 350 | if (level == 18) |
Pokitto | 0:411a75fba946 | 351 | { |
Pokitto | 0:411a75fba946 | 352 | game.display.drawBitmap(22, 3,face); |
Pokitto | 0:411a75fba946 | 353 | |
Pokitto | 0:411a75fba946 | 354 | } |
Pokitto | 0:411a75fba946 | 355 | draw_map(30,20,3,(level-1) * 72); |
Pokitto | 0:411a75fba946 | 356 | lptr = &leveldata[level]; |
Pokitto | 0:411a75fba946 | 357 | // draw an x for the players starting position |
Pokitto | 0:411a75fba946 | 358 | sx = (int) (lptr->startx * 3 ) + 30; |
Pokitto | 0:411a75fba946 | 359 | sy = (int) (lptr->starty * 3) + (3 * 3) + 20; |
Pokitto | 0:411a75fba946 | 360 | game.display.color = C_RED; |
Pokitto | 0:411a75fba946 | 361 | game.display.drawLine(sx - 3,sy -3,sx + 3,sy + 3); |
Pokitto | 0:411a75fba946 | 362 | game.display.drawLine(sx - 3,sy +3,sx + 3,sy - 3); |
Pokitto | 0:411a75fba946 | 363 | |
Pokitto | 0:411a75fba946 | 364 | if (game.buttons.repeat(BTN_A,0) || |
Pokitto | 0:411a75fba946 | 365 | game.buttons.repeat(BTN_LEFT,0) || |
Pokitto | 0:411a75fba946 | 366 | game.buttons.repeat(BTN_RIGHT,0)) |
Pokitto | 0:411a75fba946 | 367 | { |
Pokitto | 0:411a75fba946 | 368 | if (release_count > 1) |
Pokitto | 0:411a75fba946 | 369 | { |
Pokitto | 0:411a75fba946 | 370 | if (game.buttons.repeat(BTN_A,0)) |
Pokitto | 0:411a75fba946 | 371 | { |
Pokitto | 0:411a75fba946 | 372 | if (level > 30) level = 1; |
Pokitto | 0:411a75fba946 | 373 | lptr = &leveldata[level]; |
Pokitto | 0:411a75fba946 | 374 | // squidwx = (lptr->startx * TILESIZE); |
Pokitto | 0:411a75fba946 | 375 | // squidwy = (lptr->starty * TILESIZE) + (3 * TILESIZE); |
Pokitto | 0:411a75fba946 | 376 | // xworld = (width/2) - squidwx; |
Pokitto | 0:411a75fba946 | 377 | // yworld = (height/2) - squidwy - 15; |
Pokitto | 0:411a75fba946 | 378 | |
Pokitto | 0:411a75fba946 | 379 | zoomsize = 3; |
Pokitto | 0:411a75fba946 | 380 | squidwx = (lptr->startx * zoomsize); |
Pokitto | 0:411a75fba946 | 381 | squidwy = (lptr->starty * zoomsize) + (3 * zoomsize); |
Pokitto | 0:411a75fba946 | 382 | xworld = (width/2) - squidwx; |
Pokitto | 0:411a75fba946 | 383 | yworld = (height/2) - squidwy - 15; |
Pokitto | 0:411a75fba946 | 384 | state_count = 0; |
Pokitto | 0:411a75fba946 | 385 | angle = lptr->startangle * TWOPI; |
Pokitto | 0:411a75fba946 | 386 | angleinc = lptr->speed * (TWOPI/20); |
Pokitto | 0:411a75fba946 | 387 | dist = (int) (lptr->dist * TILESIZE); |
Pokitto | 0:411a75fba946 | 388 | ball_spins = true; |
Pokitto | 0:411a75fba946 | 389 | state = S_TRANSITION ; // should be transition |
Pokitto | 0:411a75fba946 | 390 | attract = lptr->attract / 20.0; |
Pokitto | 0:411a75fba946 | 391 | } |
Pokitto | 0:411a75fba946 | 392 | else if (game.buttons.repeat(BTN_LEFT,0)) |
Pokitto | 0:411a75fba946 | 393 | { |
Pokitto | 0:411a75fba946 | 394 | if (level > 1) level = level -1; |
Pokitto | 0:411a75fba946 | 395 | } |
Pokitto | 0:411a75fba946 | 396 | else if (game.buttons.repeat(BTN_RIGHT,0)) |
Pokitto | 0:411a75fba946 | 397 | { |
Pokitto | 0:411a75fba946 | 398 | if (level < 30) level = level +1; |
Pokitto | 0:411a75fba946 | 399 | } |
Pokitto | 0:411a75fba946 | 400 | release_count = 0; |
Pokitto | 0:411a75fba946 | 401 | |
Pokitto | 0:411a75fba946 | 402 | } |
Pokitto | 0:411a75fba946 | 403 | } |
Pokitto | 0:411a75fba946 | 404 | else |
Pokitto | 0:411a75fba946 | 405 | { |
Pokitto | 0:411a75fba946 | 406 | if (release_count < 5) release_count++ ; |
Pokitto | 0:411a75fba946 | 407 | } |
Pokitto | 0:411a75fba946 | 408 | } |
Pokitto | 0:411a75fba946 | 409 | break; |
Pokitto | 0:411a75fba946 | 410 | case S_TRANSITION: |
Pokitto | 0:411a75fba946 | 411 | { |
Pokitto | 0:411a75fba946 | 412 | zoomsize = 3 + (state_count); |
Pokitto | 0:411a75fba946 | 413 | squidwx = (lptr->startx * zoomsize); |
Pokitto | 0:411a75fba946 | 414 | squidwy = (lptr->starty * zoomsize) + (3 * zoomsize); |
Pokitto | 0:411a75fba946 | 415 | xworld = (width/2) - squidwx; |
Pokitto | 0:411a75fba946 | 416 | yworld = (height/2) - squidwy - 15; |
Pokitto | 0:411a75fba946 | 417 | draw_map(xworld,yworld,zoomsize,(level-1) * 72); |
Pokitto | 0:411a75fba946 | 418 | |
Pokitto | 0:411a75fba946 | 419 | state_count++; |
Pokitto | 0:411a75fba946 | 420 | if (state_count > (7)) |
Pokitto | 0:411a75fba946 | 421 | { |
Pokitto | 0:411a75fba946 | 422 | squidwx = (lptr->startx * TILESIZE); |
Pokitto | 0:411a75fba946 | 423 | squidwy = (lptr->starty * TILESIZE) + (3 * TILESIZE); |
Pokitto | 0:411a75fba946 | 424 | xworld = (width/2) - squidwx; |
Pokitto | 0:411a75fba946 | 425 | yworld = (height/2) - squidwy - 15; |
Pokitto | 0:411a75fba946 | 426 | state = S_PLAY; |
Pokitto | 0:411a75fba946 | 427 | } |
Pokitto | 0:411a75fba946 | 428 | |
Pokitto | 0:411a75fba946 | 429 | |
Pokitto | 0:411a75fba946 | 430 | } |
Pokitto | 0:411a75fba946 | 431 | break; |
Pokitto | 0:411a75fba946 | 432 | case S_WON: |
Pokitto | 0:411a75fba946 | 433 | case S_LOST: |
Pokitto | 0:411a75fba946 | 434 | { |
Pokitto | 0:411a75fba946 | 435 | int boxlen,cury; |
Pokitto | 0:411a75fba946 | 436 | ballsx = ballwx + xworld; |
Pokitto | 0:411a75fba946 | 437 | ballsy = ballwy + yworld; |
Pokitto | 0:411a75fba946 | 438 | |
Pokitto | 0:411a75fba946 | 439 | animframe++; |
Pokitto | 0:411a75fba946 | 440 | if (animframe > 9) animframe = 0; |
Pokitto | 0:411a75fba946 | 441 | |
Pokitto | 0:411a75fba946 | 442 | game.display.invisiblecolor = 17 ; |
Pokitto | 0:411a75fba946 | 443 | draw_world(xworld,yworld,10,(level -1) * 72,animframe * 52); |
Pokitto | 0:411a75fba946 | 444 | |
Pokitto | 0:411a75fba946 | 445 | game.display.invisiblecolor = 15 ; |
Pokitto | 0:411a75fba946 | 446 | |
Pokitto | 0:411a75fba946 | 447 | game.display.color = 0; |
Pokitto | 0:411a75fba946 | 448 | game.display.drawLine(squidsx + 5,squidsy + 5,ballsx+5,ballsy+5); |
Pokitto | 0:411a75fba946 | 449 | |
Pokitto | 0:411a75fba946 | 450 | game.display.drawBitmap(squidsx,squidsy,squiddy); |
Pokitto | 0:411a75fba946 | 451 | |
Pokitto | 0:411a75fba946 | 452 | game.display.drawBitmap(ballsx,ballsy,ball); |
Pokitto | 0:411a75fba946 | 453 | game.display.color = 0; |
Pokitto | 0:411a75fba946 | 454 | if (state == S_WON) boxlen = 6 * 8; else boxlen = 6 * 9; |
Pokitto | 0:411a75fba946 | 455 | if (squidsy > 50) cury = 20; else cury = 70; |
Pokitto | 0:411a75fba946 | 456 | |
Pokitto | 0:411a75fba946 | 457 | game.display.setCursor(30,cury); |
Pokitto | 0:411a75fba946 | 458 | draw_textbox(30,cury,boxlen,12,C_BLACK,C_DARKGREEN); |
Pokitto | 0:411a75fba946 | 459 | //game.display.color = 0; |
Pokitto | 0:411a75fba946 | 460 | //game.display.fillRectangle(28,cury-3,boxlen,12); |
Pokitto | 0:411a75fba946 | 461 | //game.display.color = C_DARKGREEN; |
Pokitto | 0:411a75fba946 | 462 | //game.display.drawRectangle(27,cury -4,boxlen+1,14); |
Pokitto | 0:411a75fba946 | 463 | |
Pokitto | 0:411a75fba946 | 464 | game.display.color = C_GREEN; |
Pokitto | 0:411a75fba946 | 465 | if (state == S_WON) |
Pokitto | 0:411a75fba946 | 466 | { |
Pokitto | 0:411a75fba946 | 467 | game.display.print("YOU WON!"); |
Pokitto | 0:411a75fba946 | 468 | } |
Pokitto | 0:411a75fba946 | 469 | else |
Pokitto | 0:411a75fba946 | 470 | { |
Pokitto | 0:411a75fba946 | 471 | game.display.print("YOU LOST!"); |
Pokitto | 0:411a75fba946 | 472 | } |
Pokitto | 0:411a75fba946 | 473 | if (game.buttons.repeat(BTN_A,0)) //if button a is pressed |
Pokitto | 0:411a75fba946 | 474 | { |
Pokitto | 0:411a75fba946 | 475 | if (release_count > 4) |
Pokitto | 0:411a75fba946 | 476 | { |
Pokitto | 0:411a75fba946 | 477 | if (state == S_WON) level = level +1; |
Pokitto | 0:411a75fba946 | 478 | release_count = 0; |
Pokitto | 0:411a75fba946 | 479 | state = S_MAP; |
Pokitto | 0:411a75fba946 | 480 | } |
Pokitto | 0:411a75fba946 | 481 | } |
Pokitto | 0:411a75fba946 | 482 | else |
Pokitto | 0:411a75fba946 | 483 | { |
Pokitto | 0:411a75fba946 | 484 | if (release_count < 5) release_count++ ; |
Pokitto | 0:411a75fba946 | 485 | } |
Pokitto | 0:411a75fba946 | 486 | } |
Pokitto | 0:411a75fba946 | 487 | break; |
Pokitto | 0:411a75fba946 | 488 | case S_PLAY : |
Pokitto | 0:411a75fba946 | 489 | { |
Pokitto | 0:411a75fba946 | 490 | if (ball_spins == true) |
Pokitto | 0:411a75fba946 | 491 | { |
Pokitto | 0:411a75fba946 | 492 | angle += angleinc; |
Pokitto | 0:411a75fba946 | 493 | ballwx = (sin(angle) * dist) + squidwx ; |
Pokitto | 0:411a75fba946 | 494 | ballwy = (cos(angle) * dist) + squidwy ; |
Pokitto | 0:411a75fba946 | 495 | } |
Pokitto | 0:411a75fba946 | 496 | else |
Pokitto | 0:411a75fba946 | 497 | { |
Pokitto | 0:411a75fba946 | 498 | angle -= angleinc; |
Pokitto | 0:411a75fba946 | 499 | squidwx = (sin(angle) * dist) + ballwx ; |
Pokitto | 0:411a75fba946 | 500 | squidwy = (cos(angle) * dist) + ballwy ; |
Pokitto | 0:411a75fba946 | 501 | } |
Pokitto | 0:411a75fba946 | 502 | |
Pokitto | 0:411a75fba946 | 503 | if (angle > TWOPI) angle -= TWOPI; |
Pokitto | 0:411a75fba946 | 504 | if (angle < -TWOPI) angle += TWOPI; |
Pokitto | 0:411a75fba946 | 505 | |
Pokitto | 0:411a75fba946 | 506 | squidsx = (int) squidwx + xworld; |
Pokitto | 0:411a75fba946 | 507 | squidsy = (int) squidwy + yworld; |
Pokitto | 0:411a75fba946 | 508 | |
Pokitto | 0:411a75fba946 | 509 | // keep player near the center of the screen |
Pokitto | 0:411a75fba946 | 510 | if (squidsx < MINSX) |
Pokitto | 0:411a75fba946 | 511 | { |
Pokitto | 0:411a75fba946 | 512 | xworld += MINSX - squidsx; |
Pokitto | 0:411a75fba946 | 513 | squidsx = MINSX; |
Pokitto | 0:411a75fba946 | 514 | } |
Pokitto | 0:411a75fba946 | 515 | |
Pokitto | 0:411a75fba946 | 516 | if (squidsx > MAXSX) |
Pokitto | 0:411a75fba946 | 517 | { |
Pokitto | 0:411a75fba946 | 518 | xworld += MAXSX - squidsx; |
Pokitto | 0:411a75fba946 | 519 | squidsx = MAXSX; |
Pokitto | 0:411a75fba946 | 520 | } |
Pokitto | 0:411a75fba946 | 521 | if (squidsy < MINSY) |
Pokitto | 0:411a75fba946 | 522 | { |
Pokitto | 0:411a75fba946 | 523 | yworld += MINSY - squidsy; |
Pokitto | 0:411a75fba946 | 524 | squidsy = MINSY; |
Pokitto | 0:411a75fba946 | 525 | } |
Pokitto | 0:411a75fba946 | 526 | if (squidsy > MAXSY) |
Pokitto | 0:411a75fba946 | 527 | { |
Pokitto | 0:411a75fba946 | 528 | yworld += MAXSY - squidsy; |
Pokitto | 0:411a75fba946 | 529 | squidsy = MAXSY; |
Pokitto | 0:411a75fba946 | 530 | } |
Pokitto | 0:411a75fba946 | 531 | |
Pokitto | 0:411a75fba946 | 532 | ballsx = ballwx + xworld; |
Pokitto | 0:411a75fba946 | 533 | ballsy = ballwy + yworld; |
Pokitto | 0:411a75fba946 | 534 | |
Pokitto | 0:411a75fba946 | 535 | // maybe the bitmap draws are faster if the invisible color is > 15? |
Pokitto | 0:411a75fba946 | 536 | game.display.invisiblecolor = 17 ; |
Pokitto | 0:411a75fba946 | 537 | animframe++; |
Pokitto | 0:411a75fba946 | 538 | if (animframe > 9) animframe = 0; |
Pokitto | 0:411a75fba946 | 539 | |
Pokitto | 0:411a75fba946 | 540 | draw_world(xworld,yworld,10,(level -1) * 72,(animframe) * 52); |
Pokitto | 0:411a75fba946 | 541 | |
Pokitto | 0:411a75fba946 | 542 | game.display.invisiblecolor = 15 ; |
Pokitto | 0:411a75fba946 | 543 | |
Pokitto | 0:411a75fba946 | 544 | game.display.color = 0; |
Pokitto | 0:411a75fba946 | 545 | game.display.drawLine(squidsx + 5,squidsy + 5,ballsx+5,ballsy+5); |
Pokitto | 0:411a75fba946 | 546 | |
Pokitto | 0:411a75fba946 | 547 | game.display.drawBitmap(squidsx,squidsy,squiddy); |
Pokitto | 0:411a75fba946 | 548 | |
Pokitto | 0:411a75fba946 | 549 | game.display.drawBitmap(ballsx,ballsy,ball); |
Pokitto | 0:411a75fba946 | 550 | |
Pokitto | 0:411a75fba946 | 551 | // hangle magnets |
Pokitto | 0:411a75fba946 | 552 | mag_flags = 0; |
Pokitto | 0:411a75fba946 | 553 | test = read_map(ballwx, ballwy,level); |
Pokitto | 0:411a75fba946 | 554 | mag_flags |= 1 << test; |
Pokitto | 0:411a75fba946 | 555 | // if the ball isn't centered on a grid square, check more points |
Pokitto | 0:411a75fba946 | 556 | if ((((int)ballwx) % 10) >= 1) |
Pokitto | 0:411a75fba946 | 557 | { |
Pokitto | 0:411a75fba946 | 558 | test = read_map(ballwx+9, ballwy,level); |
Pokitto | 0:411a75fba946 | 559 | mag_flags |= 1 << test; |
Pokitto | 0:411a75fba946 | 560 | } |
Pokitto | 0:411a75fba946 | 561 | if ((((int)ballwy) % 10) >= 1) |
Pokitto | 0:411a75fba946 | 562 | { |
Pokitto | 0:411a75fba946 | 563 | test = read_map(ballwx, ballwy+9,level); |
Pokitto | 0:411a75fba946 | 564 | mag_flags |= 1 << test; |
Pokitto | 0:411a75fba946 | 565 | if ((((int)ballwx) % 10) >= 1) |
Pokitto | 0:411a75fba946 | 566 | { |
Pokitto | 0:411a75fba946 | 567 | test = read_map(ballwx+9, ballwy+9,level); |
Pokitto | 0:411a75fba946 | 568 | mag_flags |= 1 << test; |
Pokitto | 0:411a75fba946 | 569 | } |
Pokitto | 0:411a75fba946 | 570 | |
Pokitto | 0:411a75fba946 | 571 | } |
Pokitto | 0:411a75fba946 | 572 | if (mag_flags & (1 << 4)) {ballwx += attract; squidwx += attract;} |
Pokitto | 0:411a75fba946 | 573 | if (mag_flags & (1 << 5)) {ballwy += attract; squidwy += attract;} |
Pokitto | 0:411a75fba946 | 574 | if (mag_flags & (1 << 6)) {ballwx -= attract; squidwx -= attract;} |
Pokitto | 0:411a75fba946 | 575 | if (mag_flags & (1 << 7)) {ballwy -= attract; squidwy -= attract;} |
Pokitto | 0:411a75fba946 | 576 | |
Pokitto | 0:411a75fba946 | 577 | |
Pokitto | 0:411a75fba946 | 578 | |
Pokitto | 0:411a75fba946 | 579 | |
Pokitto | 0:411a75fba946 | 580 | // see if squiddy has won or lost |
Pokitto | 0:411a75fba946 | 581 | |
Pokitto | 0:411a75fba946 | 582 | test = read_map(squidwx+ 5, squidwy+8,level); |
Pokitto | 0:411a75fba946 | 583 | |
Pokitto | 0:411a75fba946 | 584 | |
Pokitto | 0:411a75fba946 | 585 | #if 1 |
Pokitto | 0:411a75fba946 | 586 | if (test == 0) |
Pokitto | 0:411a75fba946 | 587 | { |
Pokitto | 0:411a75fba946 | 588 | state = S_LOST; |
Pokitto | 0:411a75fba946 | 589 | release_count = 0; |
Pokitto | 0:411a75fba946 | 590 | } |
Pokitto | 0:411a75fba946 | 591 | if (test == 2) |
Pokitto | 0:411a75fba946 | 592 | { |
Pokitto | 0:411a75fba946 | 593 | state = S_WON; |
Pokitto | 0:411a75fba946 | 594 | release_count = 0; |
Pokitto | 0:411a75fba946 | 595 | } |
Pokitto | 0:411a75fba946 | 596 | #endif |
Pokitto | 0:411a75fba946 | 597 | if (game.buttons.repeat(BTN_A,0)) //if button a is pressed |
Pokitto | 0:411a75fba946 | 598 | { |
Pokitto | 0:411a75fba946 | 599 | if (release_count > 1) |
Pokitto | 0:411a75fba946 | 600 | { |
Pokitto | 0:411a75fba946 | 601 | ball_spins = !ball_spins; |
Pokitto | 0:411a75fba946 | 602 | angle = angle + 3.14159265359; |
Pokitto | 0:411a75fba946 | 603 | release_count = 0; |
Pokitto | 0:411a75fba946 | 604 | } |
Pokitto | 0:411a75fba946 | 605 | } |
Pokitto | 0:411a75fba946 | 606 | else |
Pokitto | 0:411a75fba946 | 607 | { |
Pokitto | 0:411a75fba946 | 608 | if (release_count < 5) release_count++ ; |
Pokitto | 0:411a75fba946 | 609 | } |
Pokitto | 0:411a75fba946 | 610 | } |
Pokitto | 0:411a75fba946 | 611 | } |
Pokitto | 0:411a75fba946 | 612 | } |
Pokitto | 0:411a75fba946 | 613 | } |
Pokitto | 0:411a75fba946 | 614 | return 1; |
Pokitto | 0:411a75fba946 | 615 | } |
Pokitto | 0:411a75fba946 | 616 |