Join us on Discord!
You can help CodeWalrus stay online by donating here.

SwipeCE - A Swipe Arrows Port for the TI 84+ CE

Started by Unicorn, May 06, 2016, 07:33:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Unicorn

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 gameplay and color modes are planned, and should come out soon :)

Screenshot:




//--------------------------------------
// 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 */
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
  • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



??? ??? ??? ??? ???

Dream of Omnimaga

Nice, I never played that gaame before so I need to check how to play before giving feedback, but it seems like a cool idea :3=
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Unicorn

Quote from: DJ Omnimaga on May 06, 2016, 09:33:20 PM
Nice, I never played that gaame before so I need to check how to play before giving feedback, but it seems like a cool idea :3=
Thanks!

I just updated it, I completed the timer and tweaked it, now I need to figure out how to use palettes to change colors...
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
  • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



??? ??? ??? ??? ???

Dream of Omnimaga

By the way, I didn't have time to try it yet but is there a time limit to press each arrow? Also how would color-based gameplay work?
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Unicorn

Yup, there is a time limit, which decreases ever 10 points, and color based would just change the colors ever 20 points ;)
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
  • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



??? ??? ??? ??? ???

Dream of Omnimaga

I was more curious about what colors actually do in the game. :P
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Unicorn

Update: Added color, I'm working on color changing and other modes.


Download in the OP
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
  • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



??? ??? ??? ??? ???

Dream of Omnimaga

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

alexgt

  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Dudeman313

  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Powered by EzPortal