Author Topic: [C] Rainbow Dash Cloud Attack  (Read 13707 times)

0 Members and 1 Guest are viewing this topic.

Offline gameblabla

  • LV3 Member (Next: 100)
  • ***
  • Posts: 86
  • Rating: +17/-1
    • View Profile
    • Gameblabla's website
[C] Rainbow Dash Cloud Attack
« on: August 03, 2013, 03:12:54 pm »

Hi !
You asked for it , there it is !
You play as Rainbow Dash and you need to grab all the white clouds and kick the storm clouds !
You score 100 pts for each cloud you grab and score 300 pts if you kick a storm cloud.
The maximum score you can get is 99999 , i dare you to reach that !
Hope you'll enjoy it !

Download : (You need Ndless installed on your TI-nspire)
Version 1.05

Screenshots :

« Last Edit: August 04, 2013, 10:23:20 pm by gameblabla »

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: [C] Rainbow Dash Cloud Attack
« Reply #1 on: August 03, 2013, 03:37:09 pm »
Quote
That's because i need to write a integer to a file but fscanf() is not available in Ndless...
fgetc() works but only writes a char...
Just choose an endianness for your serialization of integers, and use fgetc on the integer shifted by 8, 16 and 24 then and'ed with 0xFF :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [C] Rainbow Dash Cloud Attack
« Reply #2 on: August 03, 2013, 03:51:33 pm »
yaaaaaaaaay :D
Also, can you still kill the black clouds if you hit 'em right at the end? (and giving more points)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline gameblabla

  • LV3 Member (Next: 100)
  • ***
  • Posts: 86
  • Rating: +17/-1
    • View Profile
    • Gameblabla's website
Re: [C] Rainbow Dash Cloud Attack
« Reply #3 on: August 03, 2013, 05:51:38 pm »
Quote
That's because i need to write a integer to a file but fscanf() is not available in Ndless...
fgetc() works but only writes a char...
Just choose an endianness for your serialization of integers, and use fgetc on the integer shifted by 8, 16 and 24 then and'ed with 0xFF :)
^^' Sorry , i don't understand...
But i found a way to get the save working. It is not precise at all but it works well with my game.

yaaaaaaaaay :D
Also, can you still kill the black clouds if you hit 'em right at the end? (and giving more points)
No , you can't do that. This will probably be in the next update.

EDIT : A new update is available , you can now save your highscore ! http://goo.gl/ZCY4yz
« Last Edit: August 03, 2013, 06:07:07 pm by gameblabla »

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [C] Rainbow Dash Cloud Attack
« Reply #4 on: August 03, 2013, 06:49:49 pm »
You code fast O.O

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline gameblabla

  • LV3 Member (Next: 100)
  • ***
  • Posts: 86
  • Rating: +17/-1
    • View Profile
    • Gameblabla's website
Re: [C] Rainbow Dash Cloud Attack
« Reply #5 on: August 04, 2013, 12:20:05 am »
You code fast O.O
Indeed.
I have released a new version (i think this will be the last one) , you can now kick clouds !

Download link : http://goo.gl/i3DWR6

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [C] Rainbow Dash Cloud Attack
« Reply #6 on: August 04, 2013, 04:33:55 am »
ok, now i /really/ need a cx, great job!

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: [C] Rainbow Dash Cloud Attack
« Reply #7 on: August 04, 2013, 10:05:17 am »
That looks like some nice animations with the kicking. Will definitely appeal to MLP Fans :).
Also why is the max points 25500?
« Last Edit: August 04, 2013, 10:05:30 am by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline gameblabla

  • LV3 Member (Next: 100)
  • ***
  • Posts: 86
  • Rating: +17/-1
    • View Profile
    • Gameblabla's website
Re: [C] Rainbow Dash Cloud Attack
« Reply #8 on: August 04, 2013, 01:44:57 pm »
Thanks everybody !
I have released a new version (again) , it fixes some bugs.
http://goo.gl/OIwqpV

Also why is the max points 25500?
For each (white) cloud you touch , you get 100 pts and if you kick a black one , you get 200 pts.
I can only store a char , what can i do ? (the max value for an unsigned char is 255)
Easy , i divide the highscore by 100 and then the program saves the highscore.
When the game will read the savefile , it will multiply the highscore stored in the file by 100.
I know, Lionel would not be proud of me...

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [C] Rainbow Dash Cloud Attack
« Reply #9 on: August 04, 2013, 01:47:42 pm »
Can't you somehow do 2-byte vars?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline gameblabla

  • LV3 Member (Next: 100)
  • ***
  • Posts: 86
  • Rating: +17/-1
    • View Profile
    • Gameblabla's website
Re: [C] Rainbow Dash Cloud Attack
« Reply #10 on: August 04, 2013, 02:54:46 pm »
Code: [Select]
               
sc = (highscore / 10000) % 10;
dscore[0]=sc;
sc = (highscore / 1000) % 10;
dscore[1]=sc;
sc = (highscore / 100) % 10;
dscore[2]=sc;
sc = (highscore / 10) % 10;
dscore[3]=sc;
sc = highscore % 10;
dscore[4]=sc;

file = fopen("/documents/rdsave.save.tns", "w+");
                        fputc( dscore[0], file);
fputc( dscore[1], file);
                        fputc( dscore[2], file);
fputc( dscore[3], file);
fputc( dscore[4], file);
fclose(file);

I'm really stupid , i should have done this done before. Thanks Lionel...
You can download the new update here : http://goo.gl/xJyaqb
The max pts is now 99999.

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: [C] Rainbow Dash Cloud Attack
« Reply #11 on: August 04, 2013, 03:04:57 pm »
What I meant was really shifts and ands, not division and modulo on a processor without a divide instruction :)
Code: [Select]
uint32_t ReadLongBigEndian (void) {
    uint32_t temp_long;
    temp_long  = fgetc(output) << 24;
    temp_long |= fgetc(output) << 16;
    temp_long |= fgetc(output) << 8;
    temp_long |= fgetc(output);
    return temp_long;
}

uint32_t ReadLongLittleEndian (void) {
    uint32_t temp_long;
    temp_long  = fgetc(output);
    temp_long |= fgetc(output) << 8;
    temp_long |= fgetc(output) << 16;
    temp_long |= fgetc(output) << 24;
    return temp_long;
}

void WriteIntBigEndian (uint32_t long_in) {
    fputc (((int)(long_in >> 24)) & 0xFF, output);
    fputc (((int)(long_in >> 16)) & 0xFF, output);
    fputc (((int)(long_in >>  8)) & 0xFF, output);
    fputc (((int)(long_in      )) & 0xFF, output);
    fflush(output);
}

void WriteIntLittleEndian (uint32_t long_in) {
    fputc (((int)(long_in      )) & 0xFF, output);
    fputc (((int)(long_in >>  8)) & 0xFF, output);
    fputc (((int)(long_in >> 16)) & 0xFF, output);
    fputc (((int)(long_in >> 24)) & 0xFF, output);
    fflush(output);
}

Also, another piece of general advice: don't put .tns files at the root of /documents, because TILP cannot cope with them, which means that users couldn't backup such files once your program has created them.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [C] Rainbow Dash Cloud Attack
« Reply #12 on: August 04, 2013, 08:18:45 pm »
Also, another piece of general advice: don't put .tns files at the root of /documents, because TILP cannot cope with them, which means that users couldn't backup such files once your program has created them.
Eh, that's quite annoying, can't it be fixed ? (I'm among probably many of users for who the root is just a mess :D)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline gameblabla

  • LV3 Member (Next: 100)
  • ***
  • Posts: 86
  • Rating: +17/-1
    • View Profile
    • Gameblabla's website
Re: [C] Rainbow Dash Cloud Attack
« Reply #13 on: August 04, 2013, 09:47:55 pm »
What I meant was really shifts and ands, not division and modulo on a processor without a divide instruction :)
Code: [Select]
uint32_t ReadLongBigEndian (void) {
    uint32_t temp_long;
    temp_long  = fgetc(output) << 24;
    temp_long |= fgetc(output) << 16;
    temp_long |= fgetc(output) << 8;
    temp_long |= fgetc(output);
    return temp_long;
}

uint32_t ReadLongLittleEndian (void) {
    uint32_t temp_long;
    temp_long  = fgetc(output);
    temp_long |= fgetc(output) << 8;
    temp_long |= fgetc(output) << 16;
    temp_long |= fgetc(output) << 24;
    return temp_long;
}

void WriteIntBigEndian (uint32_t long_in) {
    fputc (((int)(long_in >> 24)) & 0xFF, output);
    fputc (((int)(long_in >> 16)) & 0xFF, output);
    fputc (((int)(long_in >>  8)) & 0xFF, output);
    fputc (((int)(long_in      )) & 0xFF, output);
    fflush(output);
}

void WriteIntLittleEndian (uint32_t long_in) {
    fputc (((int)(long_in      )) & 0xFF, output);
    fputc (((int)(long_in >>  8)) & 0xFF, output);
    fputc (((int)(long_in >> 16)) & 0xFF, output);
    fputc (((int)(long_in >> 24)) & 0xFF, output);
    fflush(output);
}

Hehe , thank you Lionel ! I will certainly use it for my future projects !

Also, another piece of general advice: don't put .tns files at the root of /documents, because TILP cannot cope with them, which means that users couldn't backup such files once your program has created them.
Thanks for the advice , i did a small update to fix that. (Go download it in my first post)
The savefile is now stored in ndless's folder.

I think that will be the last update for my game , i guess it's time to work on another game...
Thank you guys for your support !
« Last Edit: August 04, 2013, 11:53:28 pm by gameblabla »