How excited are you for this project???
SUPER EXCITED!!
 9%  [ 19 ]
SUPER FRUITY EXCITED!!
 44%  [ 89 ]
All of the above
 46%  [ 93 ]
Total Votes : 201

Progress. Created and added a watermelon sprite.



Obviously you can see the screen/watermelon flashing sometimes, I'm just still getting used to the language. Eventually I'll implement the buffer, I think that will fix things.

[[GitHub Repo Here]]

EDIT: Current code (no, not optimized)

Code:
/*
 *--------------------------------------
 * Program Name:CSWIPE
 * Author:Michael2_3B
 * License:MIT
 * Description:An experimental C program to swipe like you do in fruit ninja.
 *--------------------------------------
*/

/* Keep these headers */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

/* Standard headers (recommended) */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <graphx.h>
#include <keypadc.h>

/* Include the sprite data */
#include "gfx/logo_gfx.h"

/* Put your function prototypes here */

/* Put all your globals here */

void main(void) {
    /* Fill in the body of the main function here */
    kb_key_t key;
    int xList[1000];
    int yList[1000];
    int i=0;
    int index=0;
    int x;
    int y;
    int gameTime = 0;
    double speed = 1;
    double entityX[20] = {20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    double entityY[20] = {120,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240};
    gfx_Begin();
    gfx_FillScreen(gfx_blue);
    gfx_SetColor(gfx_white);
    gfx_ScaledTransparentSprite_NoClip(watermelon, entityX[0], entityY[0], 3, 3);

    do {
       kb_Scan();
       x=0;
       y=0;
       if (kb_Data[2]) {
          key = kb_Data[2];
          x=32;
          if(key == kb_Store)
             y=188;
          if(key == kb_Ln)
             y=154;
          if(key == kb_Log)
             y=120;
          if(key == kb_Square)
             y=85;
          if(key == kb_Recip)
             y=51;
          if(key == kb_Math)
             y=17;
       }
       if (kb_Data[3]) {
          key = kb_Data[3];
          x=96;
          if(key == kb_0)
             y=222;
          if(key == kb_1)
             y=188;
          if(key == kb_4)
             y=154;
          if(key == kb_7)
             y=120;
          if(key == kb_Comma)
             y=85;
          if(key == kb_Sin)
             y=51;
          if(key == kb_Apps)
             y=17;
       }
       if (kb_Data[4]){
          key = kb_Data[4];
          x=160;
          if(key == kb_DecPnt)
             y=222;
          if(key == kb_2)
             y=188;
          if(key == kb_5)
             y=154;
          if(key == kb_8)
             y=120;
          if(key == kb_LParen)
             y=85;
          if(key == kb_Cos)
             y=51;
          if(key == kb_Prgm)
             y=17;
       }
       if (kb_Data[5]) {
          key = kb_Data[5];
          x=224;
          if(key == kb_Chs)
             y=222;
          if(key == kb_3)
             y=188;
          if(key == kb_6)
             y=154;
          if(key == kb_9)
             y=120;
          if(key == kb_RParen)
             y=85;
          if(key == kb_Tan)
             y=51;
          if(key == kb_Vars)
             y=17;
       }
       if (kb_Data[6]) {
          key = kb_Data[6];
          x=288;
          if(key == kb_Enter)
             y=222;
          if(key == kb_Add)
             y=188;
          if(key == kb_Sub)
             y=154;
          if(key == kb_Mul)
             y=120;
          if(key == kb_Div)
             y=85;
          if(key == kb_Power)
             y=51;
          if(key == kb_Clear)
             y=17;
       }
       if(y>0){
          if(index>0){
             if(x==xList[index-1] && y==yList[index-1])
                index--;
          }
          xList[index] = x;
          yList[index] = y;
          if(index>0)
             gfx_Line(xList[index-1],yList[index-1],x,y);
          index++;
          i=0;
          if(index==1000)
             index=0;
       } else {
          if(i < 101)
             i++;
          if(i==100){
             gfx_FillScreen(gfx_blue);
             gfx_ScaledTransparentSprite_NoClip(watermelon, entityX[0], entityY[0], 3, 3);
             index=0;
          }
       }
       if(index>3){
          gfx_SetColor(gfx_blue);
          gfx_Line(xList[index-4],yList[index-4],xList[index-3],yList[index-3]);
          gfx_SetColor(gfx_white);
       }
   
    gfx_End();

}

/* Put other functions here */



EDIT 2: These new fruits look awesome, don't they? I made them myself!


However, if you think you can do better than me in drawing sprites, be my guest. I'll gladly add you as coauthor if I like your work. Sprites must be no larger than 32x32. For reference, here are all the main sprites that the program will need:

Code:
Watermelons
Mangoes
Pineapples
Coconuts
Strawberries
Red Apples
Green Apples
Kiwis
Yellow Bananas
Lemons
Limes
Oranges
Plums
Pears
Passionfruits
Peaches

Bombs

Dragon Fruits
Pomegranates
Progress!


The graphics look a bit buggy, but I did implement the buffer.

I now have a function to throw the fruits, which take an input of the sprite name, startX, startY, the angle to throw it at, and the starting velocity!
So I heard that slicing fruits in half might be an important part of the game:

(CEmu makes it look faster here than it actually is, in reality it is normal speed)

I still need to adjust some sprite sizes and how I calculate if a sprite was hit, but it pretty much works!

In addition, I added dynamic line thickness, so if you take slightly longer to go between one button and another button in a swipe, the line doubles in thickness. It's not very noticeable but it's there.

Clipping is fixed as well.

EDIT: Per TLM's request, the sprites I am already using are: watermelon, apple, pineapple, pear, and strawberry. Feel free to make or remake any sprites, as listed in the top post of this page, if you think you are a better artist than me! However I am pretty proud of my watermelon so I won't be giving that one away Razz

There are three sprites that must be included for every fruit, by the way. This is the whole fruit, the top half of the sliced fruit, and the bottom half of the sliced fruit. Feel free to compete with others making sprites if you like.
Spectacular work!
I did a lemon and a banana. I kept the images at 32x32 regardless of size, but kept the background transparent. You can easily resize them if you want.
I'll probably do more later when I have time; meanwhile, you can view what I've done so far here: https://imgur.com/a/UPD1TNj
I'm not quite happy with the top part of the lemon and may revise it.

Banana
Thanks TheLastMillennial! Those look pretty great.

At the moment, I'm having trouble detecting if a line touches a sprite. It may look like it works in the above picture, but actually it slices the fruit sometimes even when you didn't touch it. Does anyone know, how would you detect if a line goes through or touches within a certain rectangular area, that is, the sprite?
https://gist.github.com/ChickenProp/3194723
I guess this is progress, but it's not at all what the final product will look like. I need to implement rotation in a different way, because this looks bad. Also the fruits aren't centered in each of their files yet.

I was thinking about making 1 or 2 more sprites for different faces of each of the fruits to simulate z-rotation. It will take work but I'll see if I can get that in the next few days.

You'll notice that the game slows when swiping, I have yet to fix this as well.



And yes, I have changed the background color a few times. A good looking backdrop will possibly come later.
Great work so far! I'm impressed! Hopefully I'll get some time to make those sprites I promised.
One question unrelated to the program, when you quit, what was that character under your cursor and why is it there? Razz
TheLastMillennial wrote:
One question unrelated to the program, when you quit, what was that character under your cursor and why is it there? Razz

Looks like the empty box character. No clue why Razz
Michael2_3B wrote:
TheLastMillennial wrote:
One question unrelated to the program, when you quit, what was that character under your cursor and why is it there? Razz

Looks like the empty box character. No clue why Razz

If I were to take a guess, I'd say that it has to do with the graphics, but that may not be the best or correct explanation, because with gfx, I usually get random b/w pixels on the homescreen and random colored ones on the graphscreen, but they have no other effect. This may just be a C quirk, or maybe it's a weird Easter egg Razz
Looking good so far, I think centering the sprite graphics will make things look a lot better too - more rotation frames would help as mentioned.

There is a routine in the toolchain that can rotate+scale a sprite ... not sure if it will be fast enough at this point, plus it is unclipped.
I like it! Can you add different slice patterns? not just one? It kinda gets weird watching apples split co cleanly in half all the time. Wink Also, how about some gooey stuff? Like watermelon juice dripping out of that?
jcgter777 wrote:
I like it! Can you add different slice patterns? not just one? it kinda gets weird watching apples split co cleanly in half all the time. Wink Also, how about some gooey stuff? Like watermelon juice dripping out of that?

Ooh, I like the juice idea! It could be like a non-obtrusive transparent color that gets left behind for a little while on the view screen, simulating a dirty camera lens...


As for the different slice patterns, I could try and roughen it up a bit, however actually slicing them in half in all kinds of unique directions would require an immense number of sprites. Sprites can't simply split in half, you know, there actually has to be a sprite for the top half and the bottom half.

If you look at the monochrome version of Fruit Ninja, you'll notice that this is the same situation - no matter which way you slice, it always gets cut in half the same way.


EDIT:
To-Do for now:
-implement a bomb!
-add a few different sprite faces for the fruits (and smooth out fruit rotation)
-optimize swiping collision detection
-add a proper backdrop
-add fruit juice leftovers to screen
-and of course, add more fruit sprites
Michael2_3B wrote:
jcgter777 wrote:
I like it! Can you add different slice patterns? not just one? it kinda gets weird watching apples split co cleanly in half all the time. Wink Also, how about some gooey stuff? Like watermelon juice dripping out of that?

Ooh, I like the juice idea! It could be like a non-obtrusive transparent color that gets left behind for a little while on the view screen, simulating a dirty camera lens...

As for the different slice patterns, I could try and roughen it up a bit, however actually slicing them in half in all kinds of unique directions would require an immense number of sprites. Sprites can't simply split in half, you know, there actually has to be a sprite for the top half and the bottom half.

If you look at the monochrome version of Fruit Ninja, you'll notice that this is the same situation - no matter which way you slice, it always gets cut in half the same way.


I kinda thought about that. Would two for each fruit be too much? For the goo, I was thinking like something could drop out of it. (one sprite is probably good for that)
This is my first time seeing this and it looks spectacular. I might have to get a CE sometime, it looks like it has a multitude of impressive programs available for it now.
This is amazing! Very Happy Do you have any idea when you may finish?
He'll finish when he finishes. He'll release a beta when he feels like it. Same with DoorsCE, AoCE, and whatever else there is. Just chill out and wait. Wink
Edit: this is my 777th post!!!

Woohoo, more eye candy! So, this is my first attempt at a "game over" explosion for the bombs...

None of the timings for throwing anything is configured yet, by the way. Bombs will be more rare in the future.

CalebHansberry wrote:
This is my first time seeing this and it looks spectacular. I might have to get a CE sometime, it looks like it has a multitude of impressive programs available for it now.

You definitely should! The cost isn't all that nice but I'd say it's worth it.
I thought the bombs obliterated all fruits on screen? If not, maybe add something that does.
Looking awesome; the rotation is near perfect. Smile

I would suggest setting up a frame timer using one of the hardware timers. This way you can either check if it has expired or wait for it to; that way you don't get the speed issues.
  
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
» Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
» View previous topic :: View next topic  
Page 2 of 9
» 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