Hey everyone! I'm going to attempt to port the Don't Touch the Spikes iPhone/Android game.

Just a warning, it may not be exactly the same, but the game will have the same principle.

So far I have no progress, except for testing things out in basic, I was waiting to make sure the SC3 was up to date with the C libraries. Anyways I probably am going to have a hard time testing the program as there is no online CE emulator, but I think in a few days ill be able to download CEmu. If someone would like to test for me, please PM me. Smile


Anyways, I hope to get something done. Very Happy
Turns out I did get something done, and I may upload it to the archives soon Smile
I've implemented high-scores, and every 6 points you get the color of your ball is changed. Every time you bounce off of both sides once, the colors are rearranged. Let me know what you think!

I'm planning to add a currency which you will be able to use to buy different backgrounds and character sprites, like a rectangle, or a star, or something. I probably will also add color changing options as well, sort of like in StackerCE.


Code:

// Program Name:
// Author(s):
// Description:

/* Keep these headers */
#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 <debug.h>
/* Other available headers */
// including stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h

/* Available libraries */
// including lib/ce/graphc.h, lib/ce/fileioc.h, and lib/ce/keypadc.h
#include <lib/ce/graphx.h>
#include <lib/ce/keypadc.h>
#include <lib/ce/fileioc.h>
/* Put your function prototypes here */
void setColors(int color1, int color2, int color3, int color4, int color5);
void draw(void);
void setColor(void);
void inGame(void);
/* Put all your globals here. */
int Gcolor1, Gcolor2, Gcolor3, Gcolor4, Gcolor5,colorChange, key, time, random, colorChoice, keyPress, getPixelLeft, getPixelRight, score;
ti_var_t file;
uint8_t highscore;
bool quit, up, left = true, timer, userColor, userColor1;
/* Put all your code here */

void main() {
   ti_CloseAll();
   file = ti_Open("swipehigh", "r");
   if (file) {
      ti_Read(&highscore, sizeof(highscore), 1, file);
    }   
    else {
       highscore = 0;
    }
    srand( rtc_Time() );
    gfx_Begin(gfx_8bpp);
    gfx_FillScreen(181);
    gfx_PrintStringXY("Don't Touch the Wrong Color!",60,1);
    gfx_PrintStringXY("Press any key to play",85,11);
   gfx_PrintStringXY("Highscore:",105,51);
   gfx_SetTextXY(180,51);
   gfx_PrintInt(highscore, 3);
    while(kb_ScanGroup(kb_group_6) != kb_Clear) {
        if (kb_AnyKey()) {
            gfx_FillScreen(181);
            setColors(31,255,95,236,186);
            draw();
         inGame();
        }
      if (quit == true)
         break;
        key = kb_ScanGroup(kb_group_1);  //2nd
    }
    gfx_End();
    prgm_CleanUp();
}
void draw(void){
   userColor1 = false;
    setColor();
    gfx_FillRectangle(0, 0, 16, 60);
    setColor();
    gfx_FillRectangle(0, 60, 16, 60);
    setColor();
    gfx_FillRectangle(0, 120, 16, 60);
    setColor();
    gfx_FillRectangle(0, 180, 16, 60);
   if (userColor1 == false) {
      gfx_SetColor(Gcolor5);
      random = randInt(1,4);
      if (random == 1)
         gfx_FillRectangle(0, 0, 16, 60);
      if (random == 2)
         gfx_FillRectangle(0, 60, 16, 60);
      if (random == 3)
         gfx_FillRectangle(0, 120, 16, 60);
      if (random == 4)
         gfx_FillRectangle(0, 180, 16, 60);
   }
   userColor1 = false;   
    setColor();
    gfx_FillRectangle(308, 0, 16, 60);
    setColor();
    gfx_FillRectangle(308, 60, 16, 60);
    setColor();
    gfx_FillRectangle(308, 120, 16, 60);
    setColor();
    gfx_FillRectangle(308, 180, 16, 60);
   if (userColor1 == false) {
      gfx_SetColor(Gcolor5);
      random = randInt(1,4);
      if (random == 1)
         gfx_FillRectangle(308, 0, 16, 60);
      if (random == 2)
         gfx_FillRectangle(308, 60, 16, 60);
      if (random == 3)
         gfx_FillRectangle(308, 120, 16, 60);
      if (random == 4)
         gfx_FillRectangle(308, 180, 16, 60);
   }
}
void setColor(void) {
    colorChoice = randInt(1,5);
    if (colorChoice == 1) {
        gfx_SetColor(Gcolor1);
      userColor = false;
   }
    if (colorChoice == 2) {
        gfx_SetColor(Gcolor2);
      userColor = false;
   }
    if (colorChoice == 3) {
        gfx_SetColor(Gcolor3);
      userColor = false;
   }
    if (colorChoice == 4) {
        gfx_SetColor(Gcolor4);
   }
    if (colorChoice == 5) {
        gfx_SetColor(Gcolor5);
      userColor1 = true;
   }
}
void setColors(int color1, int color2, int color3, int color4, int color5) {
    Gcolor1 = color1;
    Gcolor2 = color2;
    Gcolor3 = color3;
    Gcolor4 = color4;
    Gcolor5 = color5;
}
void inGame() {
   int posX = 160, posY = 120;
   while (kb_ScanGroup(kb_group_6) != kb_Clear) {
      gfx_SetTextXY(150, 1);
      gfx_PrintInt(score, 3);
      getPixelLeft = gfx_GetPixel(posX-16, posY);
      getPixelRight = gfx_GetPixel(posX+16, posY);
      if (keyPress % 20 == 0) {
         if (kb_ScanGroup(kb_group_7) == kb_Up)
            up = true;
         if (up == false)
            posY = posY + 4;
         if (up == true) {
            timer = true;
            posY = posY - 3;
         }
         if (left == true)
            posX = posX - 3;
         if (left == false)
            posX = posX + 3;
         if (timer == true)
            time++;
         if (time == 10) {
            time = 0;
            timer = false;
            up = false;
         }
         gfx_SetColor(181);
         if (left == true && up == false)
            gfx_FillCircle(posX+3, posY-4, 12);
         if (left == true && up == true)
            gfx_FillCircle(posX+3, posY+4, 12);
         if (left == false && up == true)
            gfx_FillCircle(posX-3, posY+4, 12);
         if (left == false && up == false)
            gfx_FillCircle(posX-3, posY-4, 12);
         gfx_SetColor(Gcolor5);
         gfx_FillCircle(posX, posY, 8);
         if (left == true && getPixelLeft == Gcolor5) {
            left = false;
            score++;
            colorChange++;
            gfx_SetTextXY(150, 1);
            gfx_SetColor(181);
            gfx_FillRectangle(150, 1, 32, 10);
            gfx_PrintInt(score, 3);
         }
         if (left == false && getPixelRight == Gcolor5) {
            draw();
            left = true;
            score++;
            colorChange++;
            gfx_SetTextXY(150, 1);
            gfx_SetColor(181);
            gfx_FillRectangle(150, 1, 32, 10);
            gfx_PrintInt(score, 3);
         }
         if (colorChange == 6) {
            random = randInt(1,5);
            if (random == 1)
               Gcolor5 = Gcolor1;
            if (random == 2)
               Gcolor5 = Gcolor2;
            if (random == 3)
               Gcolor5 = Gcolor3;
            if (random == 4)
               Gcolor5 = Gcolor4;
            if (random == 5)
               Gcolor5 = Gcolor5;
            colorChange = 0;
            draw();
         }
         if (left == true && getPixelLeft != 181 && getPixelLeft != Gcolor5)
            break;
         if (left == false && getPixelRight != 181 && getPixelRight != Gcolor5)
            break;
      }
      keyPress++;
   }
   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); 
   }
   quit = true;
}
/* Other functions */
Update!

So I've implemented a speed increase as you progress, as well as smaller rectangles of color. Once you hit 15 points or so, they will get smaller. In the screenshot I only have to reach 5, but that is for testing and demonstration purposes. Among other things, I have tweaked quitting and losing.



Code:
// Program Name:
// Author(s):
// Description:

/* Keep these headers */
#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 <debug.h>
/* Other available headers */
// including stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h

/* Available libraries */
// including lib/ce/graphc.h, lib/ce/fileioc.h, and lib/ce/keypadc.h
#include <lib/ce/graphx.h>
#include <lib/ce/keypadc.h>
#include <lib/ce/fileioc.h>
/* Put your function prototypes here */
void setColors(int color1, int color2, int color3, int color4, int color5, int color6, int color7);
void draw(void);
void setColor(void);
void inGame(void);
/* Put all your globals here. */
int Gcolor1, Gcolor2, Gcolor3, Gcolor4, Gcolor5, Gcolor6, Gcolor7, colorChange, key, time, random, colorChoice, keyPress, getPixelLeft, getPixelRight, score;
ti_var_t file;
uint8_t highscore;
bool quit, up, left = true, timer, userColor, userColor1;
/* Put all your code here */

void main() {
   ti_CloseAll();
   file = ti_Open("clrhs", "r");
   if (file) {
      ti_Read(&highscore, sizeof(highscore), 1, file);
    }   
    else {
       highscore = 0;
    }
    srand( rtc_Time() );
   gfx_Begin(gfx_8bpp);
    gfx_FillScreen(181);
    gfx_PrintStringXY("Don't Touch the Wrong Color!",60,1);
    gfx_PrintStringXY("Press any key to play",85,11);
   gfx_PrintStringXY("Highscore:",105,51);
   gfx_SetTextXY(180,51);
   gfx_PrintInt(highscore, 3);
    while(kb_ScanGroup(kb_group_6) != kb_Clear) {
        if (kb_AnyKey()) {
            gfx_FillScreen(181);
            setColors(31,255,7,235,186,224,24);
            draw();
         inGame();
         if (quit == false) {
            gfx_FillScreen(181);
            gfx_PrintStringXY("Don't Touch the Wrong Color!",60,1);
            gfx_PrintStringXY("Press any key to play",85,11);
            gfx_PrintStringXY("Highscore:",105,51);
            gfx_SetTextXY(180,51);
            gfx_PrintInt(highscore, 3);
         }
        }
      if (quit == true)
         break;
        key = kb_ScanGroup(kb_group_1);  //2nd
    }
    gfx_End();
    prgm_CleanUp();
}
void draw(void){
   if (score >= 12) {
      userColor1 = false;
      setColor();
      gfx_FillRectangle(0, 0, 16, 40);
      setColor();
      gfx_FillRectangle(0, 40, 16, 40);
      setColor();
      gfx_FillRectangle(0, 80, 16, 40);
      setColor();
      gfx_FillRectangle(0, 120, 16, 40);
      setColor();
      gfx_FillRectangle(0, 160, 16, 40);
      setColor();
      gfx_FillRectangle(0, 200, 16, 40);
      if (userColor1 == false) {
         gfx_SetColor(Gcolor5);
         random = randInt(1,6);
         if (random == 1)
            gfx_FillRectangle(0, 0, 16, 40);
         if (random == 2)
            gfx_FillRectangle(0, 40, 16, 40);
         if (random == 3)
            gfx_FillRectangle(0, 80, 16, 40);
         if (random == 4)
            gfx_FillRectangle(0, 120, 16, 40);
         if (random == 5)
            gfx_FillRectangle(0, 160, 16, 40);
         if (random == 6)
            gfx_FillRectangle(0, 200, 16, 40);
      }
      userColor1 = false;   
      setColor();
      gfx_FillRectangle(304, 0, 16, 40);
      setColor();
      gfx_FillRectangle(304, 40, 16, 40);
      setColor();
      gfx_FillRectangle(304, 80, 16, 40);
      setColor();
      gfx_FillRectangle(304, 120, 16, 40);
      setColor();
      gfx_FillRectangle(304, 160, 16, 40);
      setColor();
      gfx_FillRectangle(304, 200, 16, 40);
      if (userColor1 == false) {
         gfx_SetColor(Gcolor5);
         random = randInt(1,6);
         if (random == 1)
            gfx_FillRectangle(304, 0, 16, 40);
         if (random == 2)
            gfx_FillRectangle(304, 40, 16, 40);
         if (random == 3)
            gfx_FillRectangle(304, 80, 16, 40);
         if (random == 4)
            gfx_FillRectangle(304, 120, 16, 40);
         if (random == 5)
            gfx_FillRectangle(304, 160, 16, 40);
         if (random == 6)
            gfx_FillRectangle(304, 200, 16, 40);
      }
   }
   if (score < 12) {
      userColor1 = false;
      setColor();
      gfx_FillRectangle(0, 0, 16, 60);
      setColor();
      gfx_FillRectangle(0, 60, 16, 60);
      setColor();
      gfx_FillRectangle(0, 120, 16, 60);
      setColor();
      gfx_FillRectangle(0, 180, 16, 60);
      if (userColor1 == false) {
         gfx_SetColor(Gcolor5);
         random = randInt(1,4);
         if (random == 1)
            gfx_FillRectangle(0, 0, 16, 60);
         if (random == 2)
            gfx_FillRectangle(0, 60, 16, 60);
         if (random == 3)
            gfx_FillRectangle(0, 120, 16, 60);
         if (random == 4)
            gfx_FillRectangle(0, 180, 16, 60);
      }
      userColor1 = false;   
      setColor();
      gfx_FillRectangle(304, 0, 16, 60);
      setColor();
      gfx_FillRectangle(304, 60, 16, 60);
      setColor();
      gfx_FillRectangle(304, 120, 16, 60);
      setColor();
      gfx_FillRectangle(304, 180, 16, 60);
      if (userColor1 == false) {
         gfx_SetColor(Gcolor5);
         random = randInt(1,4);
         if (random == 1)
            gfx_FillRectangle(304, 0, 16, 60);
         if (random == 2)
            gfx_FillRectangle(304, 60, 16, 60);
         if (random == 3)
            gfx_FillRectangle(304, 120, 16, 60);
         if (random == 4)
            gfx_FillRectangle(304, 180, 16, 60);
      }
   }
}
void setColor(void) {
    colorChoice = randInt(1,7);
    if (colorChoice == 1) {
        gfx_SetColor(Gcolor1);
      userColor = false;
   }
    if (colorChoice == 2) {
        gfx_SetColor(Gcolor2);
      userColor = false;
   }
    if (colorChoice == 3) {
        gfx_SetColor(Gcolor3);
      userColor = false;
   }
    if (colorChoice == 4) {
        gfx_SetColor(Gcolor4);
   }
    if (colorChoice == 5) {
        gfx_SetColor(Gcolor5);
      userColor1 = true;
   }
   if (colorChoice == 6) {
        gfx_SetColor(Gcolor6);
      userColor1 = false;
   }
    if (colorChoice == 7) {
        gfx_SetColor(Gcolor7);
      userColor1 = false;
   }
}
void setColors(int color1, int color2, int color3, int color4, int color5, int color6, int color7) {
    Gcolor1 = color1;
    Gcolor2 = color2;
    Gcolor3 = color3;
    Gcolor4 = color4;
    Gcolor5 = color5;
   Gcolor6 = color6;
   Gcolor7 = color7;
}
void inGame() {
   int posX = 160, posY = 120;
   int speed = 20;
   while (1) {
      gfx_SetTextXY(150, 1);
      gfx_PrintInt(score, 3);
      getPixelLeft = gfx_GetPixel(posX-16, posY);
      getPixelRight = gfx_GetPixel(posX+17, posY);
      if (keyPress % speed == 0) {
         if (kb_AnyKey())
            up = true;
         if (up == false)
            posY = posY + 4;
         if (up == true) {
            timer = true;
            posY = posY - 3;
         }
         if (left == true)
            posX = posX - 3;
         if (left == false)
            posX = posX + 3;
         if (timer == true)
            time++;
         if (time == 10) {
            time = 0;
            timer = false;
            up = false;
         }
         gfx_SetColor(181);
         if (left == true && up == false)
            gfx_FillCircle(posX+3, posY-4, 11);
         if (left == true && up == true)
            gfx_FillCircle(posX+3, posY+4, 11);
         if (left == false && up == true)
            gfx_FillCircle(posX-3, posY+4, 11);
         if (left == false && up == false)
            gfx_FillCircle(posX-3, posY-4, 11);
         gfx_SetColor(Gcolor5);
         gfx_FillCircle(posX, posY, 6);
         if (left == true && getPixelLeft == Gcolor5) {
            left = false;
            score++;
            colorChange++;
            if (speed >= 1)
               speed--;
            gfx_SetTextXY(150, 1);
            gfx_SetColor(181);
            gfx_FillRectangle(150, 1, 32, 10);
            gfx_PrintInt(score, 3);
         }
         if (left == false && getPixelRight == Gcolor5) {
            draw();
            left = true;
            score++;
            colorChange++;
            gfx_SetTextXY(150, 1);
            gfx_SetColor(181);
            gfx_FillRectangle(150, 1, 32, 10);
            gfx_PrintInt(score, 3);
         }
         if (colorChange == 6) {
            random = randInt(1,5);
            if (random == 1)
               Gcolor5 = Gcolor1;
            if (random == 2)
               Gcolor5 = Gcolor2;
            if (random == 3)
               Gcolor5 = Gcolor3;
            if (random == 4)
               Gcolor5 = Gcolor4;
            if (random == 5)
               Gcolor5 = Gcolor5;
            colorChange = 0;
            draw();
         }
         if (left == true && getPixelLeft != 181 && getPixelLeft != Gcolor5)
            break;
         if (left == false && getPixelRight != 181 && getPixelRight != Gcolor5)
            break;
      }
      if (kb_ScanGroup(kb_group_6) == kb_Clear) {
         quit = true;
         break;
      }
      keyPress++;
   }
   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("clrhs", "w");
     
    /* write some things to the file */
    if (file)
         ti_Write(&highscore, sizeof(highscore), 1, file); 
   }
}
/* Other functions */

What do you think? When it gets accepted to the archives I'll post a link.
Looks cool. Good job.
Yay, I just wish I had a CE to develop on, you know? Anyway, good job.
How has this been coming along over the past month, Unicorn? It looks great so far, and I hope you've had the chance to keep improving it (although if the competing project is your Contest #17 entry, I definitely encourage you to focus on that instead).
I've actually pretty much finished it for now, I guess I never posted a link Razz

https://www.cemetech.net/programs/index.php?mode=file&path=/84pce/asm/games/DontTouchtheColor.zip

Anyways, I think I'm going to get back into my contest entry very soon, so expect development!
Unicorn wrote:
I've actually pretty much finished it for now, I guess I never posted a link Razz

https://www.cemetech.net/programs/index.php?mode=file&path=/84pce/asm/games/DontTouchtheColor.zip

Anyways, I think I'm going to get back into my contest entry very soon, so expect development!
Ah, that's great! I'm not sure that tifreak8x knew it was done; otherwise it would have showed up in PotM. Smile
  
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