- "A pet simulator"

Hello Everyone,
This week I wanted to take my mind off other projects that I had planed for this year.

So ...

I created a program called Flip Frog. Flip Frog uses "Xenon" latest graphic and mouse developer library. Your probably wondering why it's called Flip Frog. The name derives from from a DS application called Flipnote, It also uses it's frog sprites.

Right now, The program allow you to change the frog size during animations and etc (does not change color yet). But, later on I look forward to making it into a sort of pet game / simulator.

Current Demo:


*color changing does not work just yet*

What do you think about this small project? what features should I add?
It looks good! That GUI is very slick, and I'm looking forward to seeing what you can do with it in the next iteration of Xenon. As long as it isn't better than VYSION, of course. The one thing I'd say is that the mouse-over help text probably isn't necessary for all of the options, such as "change," "size," and "color." Those seem pretty self explanatory. I'd like to see some sort of custom background for the frog as well, maybe a pond or something, as I think it would make the program look more complete.
Looks great and I love the concept - will there be more animations at any stage?

Also is there the possibility for users to edit the sprites or use their own?
tr1p1ea wrote:
Looks great and I love the concept - will there be more animations at any stage?

Thank you Smile
3 animations seem reasonable, But what other animations would you like to suggest I may later on?

tr1p1ea wrote:
Also is there the possibility for users to edit the sprites or use their own?

That seems like a good very good idea! So user can basically create there own pets?
"I'll add that to the to do list"


epsilon5 wrote:
It looks good! That GUI is very slick, and I'm looking forward to seeing what you can do with it in the next iteration of Xenon. As long as it isn't better than VYSION, of course. The one thing I'd say is that the mouse-over help text probably isn't necessary for all of the options, such as "change," "size," and "color." Those seem pretty self explanatory. I'd like to see some sort of custom background for the frog as well, maybe a pond or something, as I think it would make the program look more complete.


Thank you Smile , I agree the was no need for the extra text overlay on "Size", "Change", or "color" but it was simply for the users would where wondering. (I'll remove it later).

I will be adding a ground or some type of surface later on.
Awesome! I always struggle with pixel art, so I'm envious!
JamesV wrote:
Awesome! I always struggle with pixel art, so I'm envious!

Why Thank you Razz . Banchor: Legend of the Hellspawn looks amazing and has great pixel art, your good at pixel art.
So I'm currently having an issue/bug with the color changing feature for the frog, There are currently 3 ways for me to change the sprites color.

Code:
1. Change palette index. // effects other sprites.
2. Add more sprites. // increase program size (without compression)
3. Get sprite data pointer and change previous color to new color. // simple and easy and does not effect other sprites.

I am trying to use "3", as it seems very reasonable and "safe". But I don't how to use pointers correctly so please bear with me.

Replacing Sprite Code:

Code:
void ReplaceSpriteColor(uint8_t *data[], uint8_t old_color, uint8_t new_color)
{
   int arr_len = sizeof(data[0]); // gets the array size
   
   for (int i = 0; i <= arr_len; i++){
      if (&data[i] == old_color){ // check if the data in array is equal to new data
         data[i] = &new_color;
         continue;
      }
   }
   // return *data;
}


Code:
void change_frog_colors(uint8_t curr_color)
{
   gfx_sprite_t* frog[19] = {frog_1, frog_2, frog_3, frog_4, frog_5, frog_6, frog_7, frog_8, frog_9, frog_10, frog_11,
                     frog_12, frog_13, frog_14, frog_15, frog_16, frog_17, frog_18, frog_19}; // all frog sprites
   uint8_t new_color, *ptr;
   
   new_color = ColorPicker(curr_color, 1, 1);  // User picks a color
   
   for (int i = 0; i < 20; i++){
      ptr = &frog[i]->data;
      ReplaceSpriteColor(&ptr, curr_color, new_color);
   }
   
   return;
}


For some reason it does not work, could someone please explain why?

*EDIT: I guess i will do "1", but I would still like how it to make 3 work.
Alvajoy123 wrote:

Code:
void ReplaceSpriteColor(uint8_t *data[], uint8_t old_color, uint8_t new_color)
{
   int arr_len = sizeof(data[0]); // gets the array size
   
   for (int i = 0; i <= arr_len; i++){
      if (&data[i] == old_color){ // check if the data in array is equal to new data
         data[i] = &new_color;
         continue;
      }
   }
   // return *data;
}


You can't tell how big an array passed as an argument is. sizeof(data[0]) just gets the size of the first element of the array in bytes, not the number of elements. You'll need to pass the length separately and then use that.
A trick I've heard about - but never tried - is to store the length of the array when you allocate it.
For example, you could do this:

Code:

void* temp = (malloc(number_of_elements*sizeof(type)+sizeof(int)));
((int*)temp)[0]=number_of_elements;
type* data = (type*)(temp+sizeof(int));

or something like that, where you stash the length in the element "before the first" but increment the pointer so when you "access the first element" you really get the second.
So I just update the code and I still having issues.




Code:
void change_frog_colors(uint8_t curr_color)
{
      gfx_sprite_t *frog[19] = {frog_1, frog_2, frog_3, frog_4, frog_5, frog_6, frog_7, frog_8, frog_9, frog_10, frog_11,
                     frog_12, frog_13, frog_14, frog_15, frog_16, frog_17, frog_18, frog_19};
   uint8_t new_color;
   
   // new_color = oxy_ColorPicker(curr_color, 1, 1);
   new_color = 10;
   
   for (int i = 0; i < 20; ++i){
      uint8_t *data = frog[i]->data;
      uint8_t width = frog[i]->width;
      uint8_t height = frog[i]->height;
      
      for (int j = 0; j < width * height; ++j)
      {
         if (data[j] == curr_color)
            data[j] = new_color;
      }
   }

   return;
}
I'm not too familiar with the C SDK, but it looks like you're comparing pointers with integers.
You’re not using pointers correctly in the replace sprite color function, I’d read about them and then try writing the function again. For reference, know that you can access an element stored in an array using its pointer like this:

Code:
//data is a pointer to an array of uint8_ts, new_color is a uint8_t
(*data)[i] = new_color;

I don’t know what you’re doing with memory addresses, but it’s not going to work. Also, as commandblockguy said (and I did on Discord as well), new_color and old_color should be uint8_ts.
uint8_t *data[] is an array of pointers to uint8_t. What you actually want is probably either an array of uint8_t (uint8_t data[]), or a pointer to uint8_t (uint8_t *data).
old_color and new_color should not be pointers to uint8_t but just uint8_t.
You can just do this if you want to replace the sprite data section:


Code:
for (int i = 0; i < 20; ++i)
{
    uint8_t *data = frog[i]->data;
    uint8_t width = frog[i]->width;
    uint8_t height = frog[i]->height;

    for (int j = 0; j < width * height; ++j)
    {
        if (data[j] == replace_color_index)
            data[j] = new_color_index;
    }
}
Thanks everyone for the help "turns out the crashing was cause by the sprite array (it was not a global variable so when I displayed the sprite it crashed)". Also thank you, MeteoC for the code snippet.


"There is load more bug with sprite index changing I'll fix them over night"

Code:
uint8_t change_frog_colors(const uint8_t curr_color)
{
   const uint8_t new_color = oxy_ColorPicker(curr_color, 1, 1);
   
   if (!new_color) return 0;
   
   for (int i = 0; i < 20; i++){
      uint8_t *data = frog[i]->data;
      uint8_t width = frog[i]->width;
      uint8_t height = frog[i]->height;
      
      for (int j = 0; j < width * height; j++)
      {
         if (data[j] == curr_color)
            data[j] = new_color;
      }
   }
   
   return new_color;
}
So I finished the Demo [post above] "i'll post later in cemetech archives " (users that helped would be getting their credit), It's now time for me to start working on the prototype of the game. I want to start by making 2 more animations "an eating animation and poooooop animation for the frog" (Keep in mind this is your pet Razz).

Edit: I will need to optimize the code and allow the frog to move around (by its own), before I can get any further.
Finished with frog movements (only with jump), and optimized the code a bit.



I also added an FPS counter "in the upper left of screen". The FPS rate seems to be going down when I open and object, this most likely do to the current buffer method (just filling the screen).
This reminds me of the Nintendo DSi flip note frog.
jake01756 wrote:
This reminds me of the Nintendo DSi flip note frog.


The frog sprites actually came from the flip note frog sprites, I've only added color and ported it to the calculator.
Alvajoy123 wrote:
jake01756 wrote:
This reminds me of the Nintendo DSi flip note frog.


The frog sprites actually came from the flip note frog sprites, I've only added color and ported it to the calculator.

Adorable! You're doing God's work, mate Very Happy
Seriously, imagine whipping out the TI in Calculus to feed your virtual pet frog...
  
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