Those sounds like a fun range of game modes to me. I'm sorry that no one heeded your request for switching tracks; did you ever manage to get those made?
KermMartian wrote:
Those sounds like a fun range of game modes to me. I'm sorry that no one heeded your request for switching tracks; did you ever manage to get those made?

No, I guess I did not. I'll try to find a way to create something for track switching, not sure if I will even do it anymore, with all those different gamemodes.
You could always add it in v2. Like after the contest is over.
Course, that is an option, providing I don't start more projects. (I kinda already have Razz)

Anyways, here's a screenshot showing multiple gamemodes.

So, here's an update!

- I've tweaked the menu screen around and added high-scores for both bullet and endless.
- I've created a story-line that displays when you enter campaign mode
- I've created an option to toggle the story (Pressing [Graph] )

Looks great Unicorn. Good job
Thanks!

So a question: Any idea why my setPerk() functions aren't displaying their strings?

setPerk function:

Code:

void setPerk(int perkName, const char perkStringName, int y) {
   gfx_SetTextXY(15, y);
   if (perkName == 0) {
      gfx_SetTextFGColor(148);
      gfx_PrintChar(perkStringName);
   } else if (perkName == 1) {
      gfx_SetTextFGColor(8);
      gfx_PrintChar(perkStringName);
   } else if (perkName == 2) {
      gfx_SetTextFGColor(5);
      gfx_PrintChar(perkStringName);
   }
}

Calling of setPerk() :

Code:

   gfx_FillScreen(gfx_black);
   gfx_SetTextScale(2,2);
   gfx_SetTextFGColor(8);
   gfx_PrintStringXY("Upgrades", 40, 1);
   gfx_SetTextScale(1,1);
   // 0 means unavailabe
   // 1 means able to buy
   // 2 means bought
   setPerk(slowDown1, "- Slower Trains 1", 50);
   setPerk(slowDown2, "- Slower Trains 2", 60);
   setPerk(moreMoney1, "- Better Paycheck 1", 70);
   setPerk(moreMoney2, "- Better Paycheck 2", 80);
   setPerk(moreMoney3, "- Better Paycheck 3", 90);
   setPerk(track1Switch, "- Upgrade Track 1", 100);
   setPerk(track2Switch, "- Upgrade Track 2", 110);
   setPerk(track3Switch, "- Upgrade Track 3", 120);
   setPerk(track4Switch, "- Upgrade Track 4", 130);
   if (started == true) {
      while (!kb_AnyKey()) {
      }
   }


Any ideas?
Well, you're passing a const char rather than a const char*. And using gfx_PrintChar rather than gfx_PrintString. That's about it.
MateoConLechuga wrote:
Well, you're passing a const char rather than a const char*. And using gfx_PrintChar rather than gfx_PrintString. That's about it.

I changed it and it still doesn't work. What else could I do?

I'll do more debugging in the morning when I have more time.
const char perkStringName should be const char *perkStringName, and gfx_PrintChar(perkStringName); should be gfx_PrintString(perkStringName); if it doesn't work by changing those; something somewhere else is wrong. I would also appreciate it if you would use uint8_t wherever you can; ints are worthless and waste space and performance. You aren't even using the function prototypes correctly Wink
Maybe 148 as a color doesnt display correctly with the sprites palette... But yeah, I guess I'll switch to uint8_t in the futures.

What am I not doing correctly with the prototypes?
So I've spent the better part of a day on this other problem with my appvar. Maybe someone else can spot what the problem is?

Basically, the only variable that will get saved is the first one in the struct, and even that one gets mixed up. None of the others are getting saved, so they can be read. Both ti_Read and ti_Write return 1, so they aren't failing.

My struct:

Code:

typedef struct appVar1 {
   uint8_t wallet;
    uint8_t highscore;
    uint8_t highscoreBul;
    //uint8_t wallet;
    uint8_t slowDown1;
    uint8_t slowDown2;
    uint8_t moreMoney1;
    uint8_t moreMoney2;
    uint8_t moreMoney3;
    uint8_t track1Switch;
    uint8_t track2Switch;
    uint8_t track3Switch;
    uint8_t track4Switch;
    uint8_t track1Auto;
    uint8_t track2Auto;
    uint8_t track3Auto;
    uint8_t track4Auto;
} appVar1_t;
appVar1_t appVar;

First time ti_Read is called:

Code:

   ti_CloseAll();
   readAppVar();

First time ti_Write is called:

Code:

   if (score > appVar.highscore && endless == true)
      appVar.highscore = score;
   if (score > appVar.highscoreBul && bulletmode == true)
      appVar.highscoreBul = score;
   if (gamemode == 0 && appVar.wallet == 0)
      appVar.wallet = 10;
   ti_CloseAll();
   writeAppVar();

Function writeAppVar:

Code:

void writeAppVar(void) {
   int stuff;
   //ti_CloseAll();
    ti_var_t file = ti_Open(appvar_name, "w");
    stuff = ti_Write(&appVar, sizeof(appVar), 1, file);
    dbg_sprintf(dbgout, "ti_write: %d\n", stuff);
    ti_CloseAll();
}

Function readAppVar:

Code:

void readAppVar(void) {
   int stuff;
   //ti_CloseAll();
    ti_var_t file = ti_Open(appvar_name, "r");
    stuff = ti_Read(&appVar, sizeof(appVar), 1, file);
    dbg_sprintf(dbgout, "ti_read: %d\n", stuff);
   ti_CloseAll();
}


Here's a screenshot, notice the "Balance:", "Endless:", and "Bullet:" values. Only "Balance:" is saved, and it is saved as the endless variable.
I think it's because ti_Write overwrites the entire appvar as I understand it. So what I would do, is just use your readAppVar() and writeAppVar() functions to read all the variables, and write all the variables. That's what I did.
That didn't work, but something DID work!

Not sure what it was, but Mateo helped me clean up the code posted above, and it just started working!

I'm so pumped right now Very Happy
Aaaand, second contest entry received, at least in its first form. Good luck!
Indeed, I submitted, and because I have no school tomorrow, I can work more on it tomorrow!

Anyways, here's my posting/explanation of the pretty much final game.

------------------------------------------------------------------------------------------------------------------------------------

This is a reaction based game. You must open the switches and allow trains to pass through before they crash into them.
There are four gamemodes, Campaign, Endless, and Bullet.
In campaign mode, whenever you open a switch for a train, you make money. If you let a train through without opening a switch, the train crashes and you lose money.
Endless mode just goes on forever, and you try to beat your highscore.
Bullet mode is exactly the same as endless, just without multiple trains and much faster.

Without further ado, here's a screenshot showing my making money, then buying upgrades, and then toggling things, and then playing other gamemodes. Pretty much every feature Wink



Also, if you want, check out the readme:

Quote:

_____ _ __ __ ____ __ __ __ __ _
/ ___/_ __ (_)/ /_ _____ / /_ / __ \ ____ ___ _____ ____ _ / /_ ____ _____ / /_ __ __ / / / /____ (_)_____ ____ _____ ____
\__ \| | /| / // // __// ___// __ \ / / / // __ \ / _ \ / ___// __ `// __// __ \ / ___/ ______ / __ \ / / / / / / / // __ \ / // ___// __ \ / ___// __ \
___/ /| |/ |/ // // /_ / /__ / / / / / /_/ // /_/ // __// / / /_/ // /_ / /_/ // / /_____/ / /_/ // /_/ / / /_/ // / / // // /__ / /_/ // / / / / /
/____/ |__/|__//_/ \__/ \___//_/ /_/ \____// .___/ \___//_/ \__,_/ \__/ \____//_/ /_.___/ \__, / \____//_/ /_//_/ \___/ \____//_/ /_/ /_/
/_/ /____/

v2.1

About
------------------------------------------
This is a reaction based game. You must open the switches and allow trains to pass through before they crash into them.
There are four gamemodes, Campaign, Endless, and Bullet.
In campaign mode, whenever you open a switch for a train, you make money. If you let a train through without opening a switch, the train crashes and you lose money.
Endless mode just goes on forever, and you try to beat your highscore.
Bullet mode is exactly the same as endless, just without multiple trains and much faster.

Installation
------------------------------------------
Send SWITCHOP.8xp to your calculator using TI-Connect CE or TiLP.
Make sure you have the latest version of the C libraries - https://github.com/CE-Programming/libraries/releases/
Run it with Asm(prgmSWITCHOP on the homescreen, or install Cesium to run it - https://www.cemetech.net/programs/index.php?mode=file&id=1372

Gameplay
------------------------------------------
Menu:
- You can press [Graph] to toggle the story when starting campaign, and use the Arrow Keys to Select a gamemode.
Campaign Mode:
- You have a balance that starts at $10
- Whenever you open a switch for a train, you get anywhere from 1-10 dollars, depending on the upgrade you have.
- If you let a train through, you lose anywhere from 15-7 dollars.
- You use the money you make to upgrade your system and get pay raises. You can make trains go slower, make more money per train, have switches open for longer, and make switches automatic. Once you have automatic switches, you win the game.
- You can reset on the upgrades screen with [Alpha]
- If you end up with no money, you lose and have to start over.
Endless Mode:
- This is just the base game. If you let a train through with a switch open, you get a point, if you don't open a switch for a train, you lose.
- If you get far enough, you will have to open switches for multiple trains.
- Try to beat your highscore!
Bullet Mode:
- This mode is an extension of Endless, just 2-3 times faster, and without multiple trains.

How to play
------------------------------------------
[Clear] exits every screen.
[9] opens the top track
[6] opens the second top track
[3] opens the second bottom track
[-] opens the bottom track
Unicorn, your game was great. It was quite challenging to play, which was nice. Although, I just thought it might be a little less challenging if you didn't have to time the gates because they only stay open for so long, so my opinion is that you should allow the gates to be open a little bit longer. 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 2 of 2
» 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