Well, I wasn't planning on making a post this early into the project, but SAX has encouraged me to show my code (mainly to prove my bad code works). I've been trying to learn C lately; so, like any normal person, I gave myself the unrealistic goal of creating an entire Jetpack Joyride port for a calculator and then seeing how many features I could pack in while making it extremely efficient.
So far I've got:
-Terrible background drawing function (to be replaced today or tonight)
-Controls for avatar, Barry Steakfries
-Barry sprite and simple running animation
-Coin sprites and hitbox calculations
-Coin counter
-Black boxes O' death that will be the obstacles once I've finished getting the sprites made
-FPS limiting to 25 and a counter to show what the true FPS would be if it weren't locked (for debugging really)
What needs to be done:
1. Obstacles and sprites
-Get zapper and zapper-beam hitboxes set up
*make sprites
-make missiles and hitbox calculations
*make sprites
*make little warning icons
*find an efficient way to create smoke trail effect
2. Make Barry die
-animations for death by zapper
-animations for death by missile
-bounce corpse around after death
-make a "health" system where shields add 1-5 points depending on upgrades
3. Powerups
-make all the powerups
*cash dash
*rocket time
*boost
*shield
**health system, shields only spawn at 1 health and can add more depending on upgrades
4. Vehicles
-all of them
-S.A.M. is considered a vehicle but I don't know if I'll have room for it later on
5. Custom graphics for characters, lab environment, and scientists
-graphics will be stored in an appvar with the defaults hard-coded as place holders
-should make a menu system to select which sprites from which appvar to use for each object
6. Make scientists that you can torment
Well, there's a lot to be done, but so far I've been chugging along making sprites as fast as I can. I've attempted to pull them from the .apk file (which is so easy I thought I was doing something wrong), but they're saved as .tex files, which appear to be encrypted or compressed in such a way that I can't open them. I've resorted to screenshotting my phone and then just pulling the sprites from there, which leaves much to be desired.
Anyway, here's the part that everyone actually came here to see that started WWIII in the SAX: gravity modeling!
Here's what I was using:
Code:
What it did:
...And here's what I wrote at 12 AM this morning after staying up playing Super Mario Sunshine like a responsible human being:
Code:
What the final code does (the FPS and coin counter are swapped here as a design change):
They both do the same thing, which actually is confusing me a little bit now, and I see why no one thought the cube-root function would work. I actually was using a form of the second code originally for testing, but switched to the cube-root since it was more sophisticated. There's not really any difference other than how the acceleration acts and the fact that the second way compiles 26 bytes smaller. Everyone was right about how bad it was to use a cube-root function, but it did still function normally, it just wasn't as efficient.
Congratulations, you read all of that (did you really?)! If you have any questions or comments, feel free to reply; I'll get a better version out as a GitHub repo when I feel like the code is good enough to see the light of day.
So far I've got:
-Terrible background drawing function (to be replaced today or tonight)
-Controls for avatar, Barry Steakfries
-Barry sprite and simple running animation
-Coin sprites and hitbox calculations
-Coin counter
-Black boxes O' death that will be the obstacles once I've finished getting the sprites made
-FPS limiting to 25 and a counter to show what the true FPS would be if it weren't locked (for debugging really)
What needs to be done:
1. Obstacles and sprites
-Get zapper and zapper-beam hitboxes set up
*make sprites
-make missiles and hitbox calculations
*make sprites
*make little warning icons
*find an efficient way to create smoke trail effect
2. Make Barry die
-animations for death by zapper
-animations for death by missile
-bounce corpse around after death
-make a "health" system where shields add 1-5 points depending on upgrades
3. Powerups
-make all the powerups
*cash dash
*rocket time
*boost
*shield
**health system, shields only spawn at 1 health and can add more depending on upgrades
4. Vehicles
-all of them
-S.A.M. is considered a vehicle but I don't know if I'll have room for it later on
5. Custom graphics for characters, lab environment, and scientists
-graphics will be stored in an appvar with the defaults hard-coded as place holders
-should make a menu system to select which sprites from which appvar to use for each object
6. Make scientists that you can torment
Well, there's a lot to be done, but so far I've been chugging along making sprites as fast as I can. I've attempted to pull them from the .apk file (which is so easy I thought I was doing something wrong), but they're saved as .tex files, which appear to be encrypted or compressed in such a way that I can't open them. I've resorted to screenshotting my phone and then just pulling the sprites from there, which leaves much to be desired.
Anyway, here's the part that everyone actually came here to see that started WWIII in the SAX: gravity modeling!
Here's what I was using:
Code:
//run controls until Barry gets wasted, then bounces his corpse around:
if (health > 0)
{ //controls for avatar:
if (kb_Data[1] & kb_2nd)
{
if((BarryY > 5) && (holdTime < 8))
{
holdTime += 1;
}
} else {
if((BarryY < (185)) && (holdTime > -8))
{
holdTime -= 1;
}
}
//I will never admit that I forgot about the exponent key and spent 2
//hours trying to find a cube root formula that works in C. Never.
BarryY -= ((holdTime^(1/3)));
//sees if Y-value rolled past zero or 198, figures out if it was going up
//or down, and auto-corrects accordingly:
if ((BarryY > (186)) || (BarryY < 5))
{
if (holdTime > 0)
{
BarryY = 5;
} else {
BarryY = (185);
}
holdTime = 0;
}
}
What it did:
...And here's what I wrote at 12 AM this morning after staying up playing Super Mario Sunshine like a responsible human being:
Code:
//run controls until Barry gets wasted, then bounces his corpse around:
if (health > 0)
{ //controls for avatar:
if (kb_Data[1] & kb_2nd)
{
if((BarryY > 5) && (holdTime < 12))
{
holdTime += 1;
}
} else {
if((BarryY < (185)) && (holdTime > -10))
{
holdTime -= 1;
}
}
//SAX got pretty mad about this, turns out this also models a curve and
//is actually just as good:
BarryY -= (holdTime);
//sees if Y-value rolled past zero or 198, figures out if it was going up
//or down, and auto-corrects accordingly:
if ((BarryY > (186)) || (BarryY < 5))
{
if (holdTime > 0)
{
BarryY = 5;
} else {
BarryY = (185);
}
holdTime = 0;
}
}
What the final code does (the FPS and coin counter are swapped here as a design change):
They both do the same thing, which actually is confusing me a little bit now, and I see why no one thought the cube-root function would work. I actually was using a form of the second code originally for testing, but switched to the cube-root since it was more sophisticated. There's not really any difference other than how the acceleration acts and the fact that the second way compiles 26 bytes smaller. Everyone was right about how bad it was to use a cube-root function, but it did still function normally, it just wasn't as efficient.
Congratulations, you read all of that (did you really?)! If you have any questions or comments, feel free to reply; I'll get a better version out as a GitHub repo when I feel like the code is good enough to see the light of day.