For the past week or so, I've been working on porting this game to the CE. I've finished it, more or less.

There is only one mode, the main one, and and there is no color mode. It does have a Highscore System, though!
The other gaemplay and color modes are planned, and should come out soon Smile

Screenshot:




Code:

//--------------------------------------
// Program Name:
// Author:
// License:
// Description:
//--------------------------------------

/* Keep these headers */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

/* Standard headers - it's recommended to leave them included */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <graphc.h>
#include <keypadc.h>
#include <debug.h>
#include <fileioc.h>
#include "gfx/sprites.h"
/* Other available headers */
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h

/* Put your function prototypes here */
void spritePal();
void inGame();
void menu();
void loadHS();
void setHS();
/* Put all your globals here. */
int key, key1, keyPress, swipe, rightSwipe, score = 0, color = 255, timer, timerStart, press;
ti_var_t file;
uint8_t highscore;
bool correct, keyTouched;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void main(void) {
   loadHS();
   menu();
      gc_FillScrn(255);
   gc_CloseGraph();
   pgrm_CleanUp();   
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setHS(void) {
   if (score >= highscore) {
      highscore = score;
    /* Close all open file handles before we try any funny business */
    ti_CloseAll();
     
    /* Open a file for writting*/
    file = ti_Open("swipehigh", "w");
     
    /* write some things to the file */
    if (file)
         ti_Write(&highscore, sizeof(highscore), 1, file); 
   }
}
void loadHS(void) {
   ti_CloseAll();
   file = ti_Open("swipehigh", "r");
   if (file) {
      ti_Read(&highscore, sizeof(highscore), 1, file);
    }   
    else {
       highscore = 0;
    }

}
void menu(void) {
   setHS();
   gc_InitGraph();
   gc_FillScrn(255);
   gc_InitGraph();
   gc_SetTextColor(0 | (255 << 8));
   gc_PrintStringXY("Swipe Arrow", 120, 1);
   gc_SetTextColor(192 | (255 << 8));
   gc_PrintStringXY("2nd to start", 118, 10);
   gc_PrintStringXY("Clear to exit", 117, 20);
   gc_PrintStringXY("Highscore:", 117, 50);
   gc_SetTextXY(195, 50);
   gc_PrintInt(highscore, 3);
   gc_SetPalette(sprites_pal, sizeof(sprites_pal));
   gc_NoClipDrawTransparentSprite(uparrow,120, 100, 75, 75);
   srand(rtc_Time());
   score = 0;
   while (kb_ScanGroup(kb_group_6) != kb_Clear) {
      if (keyPress % 15 == 0) {
         if (key1 & kb_2nd)
            inGame();
      }
      keyPress++;
      key = kb_ScanGroup(kb_group_7); //Arrow Keys
         key1 = kb_ScanGroup(kb_group_1);  //2nd
   }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void inGame(void) {
   gc_InitGraph();
   gc_FillScrn(255);
   gc_SetColorIndex(23);
   rightSwipe = gc_RandInt(1,8);
   timerStart = 30;
   timer = timerStart;
   while (kb_ScanGroup(kb_group_6) != kb_Clear) {
      if (keyPress % 15 == 0) {
         timer--;
         if (key & kb_Up) {
            swipe = 1;
            keyTouched = true;
            press++;
         }
         if (key & kb_Down) {
            swipe = 2;
            keyTouched = true;
            press++;
         }
         if (key & kb_Right) {
            swipe = 3;
            keyTouched = true;
            press++;
         }
         if (key & kb_Left) {
            swipe = 4;
            keyTouched = true;
            press++;
         }
         if (key & kb_Up && rightSwipe >= 5) {
            swipe = 5;
            keyTouched = true;
            press++;
         }
         if (key & kb_Down && rightSwipe >= 5) {
            swipe = 6;
            keyTouched = true;
            press++;
         }
         if (key & kb_Right && rightSwipe >= 5) {
            swipe = 7;
            keyTouched = true;
            press++;
         }
         if (key & kb_Left && rightSwipe >= 5) {
            swipe = 8;
            keyTouched = true;
            press++;
         }
         if (rightSwipe == swipe && keyTouched == true) {
            correct = true;
            keyTouched = false;
            timer = timerStart;
         }
         if (rightSwipe != swipe && keyTouched == true || timer <= 0) {
            keyTouched = false;
            gc_InitGraph();
            gc_FillScrn(255);
            gc_PrintStringXY("You Lost",120,5);
            while (kb_ScanGroup(kb_group_1) != kb_2nd) {
            }
            menu();
         }
         if (correct == true) {
            rightSwipe = gc_RandInt(1,8);
            gc_InitGraph();
            gc_SetColorIndex(color);
            gc_NoClipRectangle(120,80,75,75);
            score++;
            correct = false;
         }
      }
      if    (rightSwipe == 1) {
         spritePal();
         gc_NoClipDrawTransparentSprite(uparrow,120, 80, 75, 75);
      }
      if    (rightSwipe == 2) {
         spritePal();
         gc_NoClipDrawTransparentSprite(downarrow,120, 80, 75, 75);
      }
      if    (rightSwipe == 3) {
         spritePal();
         gc_NoClipDrawTransparentSprite(rightarrow,120, 80, 75, 75);
      }
      if    (rightSwipe == 4) {
         spritePal();
         gc_NoClipDrawTransparentSprite(leftarrow,120, 80, 75, 75);
      }
      if    (rightSwipe == 6) {
         spritePal();
         gc_NoClipDrawTransparentSprite(uparrowWrong,120, 80, 75, 75);
      }      
      if    (rightSwipe == 5) {
         spritePal();
         gc_NoClipDrawTransparentSprite(downarrowWrong,120, 80, 75, 75);
      }      
      if    (rightSwipe == 8) {
         spritePal();
         gc_NoClipDrawTransparentSprite(rightarrowWrong,120, 80, 75, 75);
      }      
      if    (rightSwipe == 7) {
         spritePal();
         gc_NoClipDrawTransparentSprite(leftarrowWrong,120, 80, 75, 75);
      }
      if (press == 10 && timerStart > 7) {
         timerStart = timerStart - 5;
         press = 0;
      }

      gc_SetColorIndex(255);
      gc_NoClipRectangle(1,1,16,16);
      gc_SetTextXY(1,1);
      gc_PrintInt(score, 3);
      keyPress++;
      key = kb_ScanGroup(kb_group_7); //Arrow Keys
         key1 = kb_ScanGroup(kb_group_1);  //2nd
   }
   menu();   
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void spritePal(void) {
   gc_SetPalette(sprites_pal, sizeof(sprites_pal));
}
/* Put other functions here */
Bump.

There is now a download here: https://www.cemetech.net/programs/index.php?mode=file&path=/84pce/asm/games/SwipeCE.zip
Smile
Bump

Update: Added color, I'm working on color changing and other modes.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement