Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
So I am attempting to create a doodle jump clone for the CE. I've gotten as far as a menu screen with a whole bunch of sprites, and I need to get double buffers working so I can erase graphics, and I've worked for a while trying to make it run fast, but to no avail. So, I'm wondering if anyone would like to try themselves to make this buffering work at an acceptable speed. Here's how fast I've gotten it (a video):

https://usercontent.irccloud-cdn.com/file/LoWwP3Fk/DoubleBuffering%2Cmp4.mp4

So there's that, and here is the code if you want to take a shot at making it work at a reasonable speed.


Code:

//--------------------------------------
// Program Name:
// Author:
// License:
// Description:
//--------------------------------------

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

/* Standard headers - it's recommended to leave them included */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <graphx.h>
#include <keypadc.h>
#include <fileioc.h>
#include <debug.h>
#include "gfx/sprites.h"
/* Other available headers */
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h

/* Put your function prototypes here */
void spriteDecompress();
void drawMenu();
/* Put all your globals here. */
gfx_image_t *splashScreen;
gfx_image_t *dLeft;
gfx_image_t *dLeftBG;
gfx_image_t *greenPlatform;
gfx_image_t *brokePlatform;
gfx_image_t *spring;
gfx_image_t *grid;
void main(void) {
   uint8_t x = 130, key = 0, keypress = 0, guyY = 168;
   bool guyUp = true;
   gfx_Begin(gfx_8bpp);
   gfx_FillScreen(gfx_white);
   gfx_SetPalette( sprites_pal, sizeof(sprites_pal), 0);
   spriteDecompress();
   gfx_SetDrawBuffer();
   drawMenu();
   gfx_SetDrawScreen();
   drawMenu();
   gfx_TransparentSprite(greenPlatform, 130, 190);
   while (kb_ScanGroup(kb_group_6) != kb_Clear) {   
         if (key & kb_Left) {
            x -= 109;
            guyY = 168;
            gfx_TransparentSprite(greenPlatform, x, 190);
         }
         if (key & kb_Right) {
            x += 109;
            guyY = 168;
            gfx_TransparentSprite(greenPlatform, x, 190);
         }
      gfx_SetDrawBuffer();
      drawMenu();
      gfx_TransparentSprite(greenPlatform, x, 190);
      gfx_PrintStringXY("Start", 145, 197);
      gfx_PrintStringXY("Settings", 30, 197);
      gfx_PrintStringXY("Quit", 262, 197);
      gfx_TransparentSprite_NoClip(dLeft, x+18, guyY);
      gfx_SwapDraw();
      gfx_SetDrawScreen();
      if (guyUp == true)
         guyY-=5;
      if (guyUp == false)
         guyY+=7;
      if (guyY <= 80)
         guyUp = false;
      if (guyY >= 168)
         guyUp = true;
      key = kb_ScanGroup(kb_group_7);
      keypress++;
   }
   gfx_End();
   pgrm_CleanUp();
}
void drawMenu(void) {
   uint8_t y = 0;
   uint24_t x = 0;
   gfx_FillScreen(214);
   gfx_SetColor(213);
   for (x = 0; x<320; x+=16) {
      gfx_Line(x, 0, x, 240);
   }
   for (y = 0; y<240; y+=16) {
      gfx_Line(0, y, 320, y);
   }

   gfx_ScaledTransparentSprite_NoClip(splashScreen, 60, 0, 2, 2);
   gfx_SetTextFGColor(8);
      gfx_PrintStringXY("Start", 145, 197);
      gfx_PrintStringXY("Settings", 30, 197);
      gfx_PrintStringXY("Quit", 262, 197);
}
void spriteDecompress(void) {
   malloc(0);
   splashScreen = gfx_AllocSprite(100, 47, malloc);
   dLeft = gfx_AllocSprite(25, 25, malloc);
   brokePlatform = gfx_AllocSprite(72, 19, malloc);
   greenPlatform = gfx_AllocSprite(75, 22, malloc);
   spring = gfx_AllocSprite(34, 17, malloc);
   grid = gfx_AllocSprite(16, 16, malloc);
   gfx_LZDecompressSprite(splashScreen_data_compressed, splashScreen);
   gfx_LZDecompressSprite(brokePlatform_data_compressed, brokePlatform);
   gfx_LZDecompressSprite(greenPlatform_data_compressed, greenPlatform);
   gfx_LZDecompressSprite(spring_data_compressed, spring);
   gfx_LZDecompressSprite(grid_data_compressed, grid);
   gfx_LZDecompressSprite(dLeft_data_compressed, dLeft);
}
/* Put other functions here */


Help would be greatly appreciated Smile
I don't know if this is at all helpful because of the different calc and language but maybe they used another method or something that could give you an idea or help you figure this out. http://tibasicdev.wikidot.com/archives:doodlejump

On a side note, what you have looks great!
The for loop in the drawMenu() function is what makes it so slow. Why not create a tilemap of one of those squares on the screen and just put that around the screen. I don't know if this works, but you might be able to draw the whole thing once and have it saved as the background. Unfortunately, I don't think there is a way in the toolchain to store a picture, kind of like in Basic. Maybe that could be requested to be added to the toolchain.

Edit:
Mateo said there is a way. I don't know how though.
Thanks for that Idea, I'm working on getting it to erase... I'm also a little worried about erasing when in-game, but I think if the screen-shifting routines are working, I should be able to do everything at a reasonable rate.

So I guess you there is a way to do it, but you need a a sprite that is teh size you need... Anyways, I've gotten everything working, and now I have to get some sort of physics working.

If someone could help me with jumping physics, that'd be great, as I know pretty much nothing about that. A link to a tutorial or something would be awesome as well, and I have done some google searches, but nothing has really made sense to me.

(The image is actually a bit slower than on-calc)
Unicorn wrote:
So I guess you there is a way to do it, but you need a a sprite that is teh size you need... Anyways, I've gotten everything working, and now I have to get some sort of physics working.

If someone could help me with jumping physics, that'd be great, as I know pretty much nothing about that. A link to a tutorial or something would be awesome as well, and I have done some google searches, but nothing has really made sense to me.

As far as physics goes, all that really needs to be done is have a variable for acceleration, and add some value to it every frame, and add that to the y-position. And then, when you jump, set it to some large negative value.

Hope I made sense...
are u still working on this?
#Tankidaboss wrote:
are u still working on this?

Haha, yes I am, though with school currently I haven had much time to code. I have gotten physics working, though, check out the screenshot!

That looks great Unicorn. My physics class just did free-fall motion. Easy problems if you use the equations.
How far has progress gone on this?
No progress from the last update, my break still stands. When school decides to let up a little, I'll have more progress.
good project, first flappy bird, then mario, and now doodle jump... It's just wonerfull! good luck Unicorn.
Are you worried about copyright laws like MateoConLechuga is with Mario?

MateoConLechuga wrote:
Because of the fear of a trademark suit or a DMCA takedown, I would rather like to make a different simpler game but still have it be a fun side scrolling platformer. Sorry Razz

https://www.cemetech.net/forum/viewtopic.php?t=11928&postdays=0&postorder=asc&start=100
TheLastMillennial wrote:
Are you worried about copyright laws like MateoConLechuga is with Mario?

MateoConLechuga wrote:
Because of the fear of a trademark suit or a DMCA takedown, I would rather like to make a different simpler game but still have it be a fun side scrolling platformer. Sorry Razz

https://www.cemetech.net/forum/viewtopic.php?t=11928&postdays=0&postorder=asc&start=100

haha, no Razz I just have no time to work on anything right now, and I had some roadblocks that I didn't bother trying to work out. I'll hopefully be able to get back at it soon Smile
So, uh, working on this again, and I have no idea how to do collision with platforms and the player, spawning platforms in so they aren't right on top of each other, and the movement of the platforms with the player as the player gets higher and higher. Anyone have a suggestions on how to do it? Here is my code if you would like to see how I currently draw everything.

EDIT: Weee! With a little coaxing from Mateo, (read: he basically gave me the answers and i was blind) i have tentitavly figured out how to do collision and fastser drawing: Getsprite for redrawing the background, rectanglse hotspot for platform drawing collision, and velocity and x values and i know hkow physics works now. Razz


Code:

void drawGame(void) {
   uint8_t y = 0;
   uint24_t x = 0;
   uint8_t i;
   gfx_FillScreen(255);
   gfx_PrintStringXY("DoodleJumpCE", 10, 2);
   gfx_PrintStringXY("By Unicorn", 19, 12);
   gfx_SetDrawScreen();
   gfx_FillScreen(255);
   gfx_PrintStringXY("DoodleJumpCE", 10, 2);
   gfx_PrintStringXY("By Unicorn", 19, 12);
   gfx_SetDrawBuffer();
   gfx_SetColor(214);
   gfx_FillRectangle(128, 0, 230, 240);
   gfx_SetColor(213);
   for (x = 128; x < 320; x += 16) {
      gfx_Line(x, 0, x, 240);
   }
   for (y = 0; y < 240; y += 16) {
      gfx_Line(128, y, 320, y);
   }
}
void renderInGame(void) {
   uint8_t y = 0;
   uint24_t x = 0;
   uint8_t i;
   bool jumperCollides = false;
   velocityY += gravity;
   guyY += velocityY;
   gfx_SetColor(214);
   gfx_FillRectangle(128, 0, 230, 240);
   gfx_SetColor(213);
   for (x = 128; x < 320; x += 16) {
      gfx_Line(x, 0, x, 240);
   }
   for (y = 0; y < 240; y += 16) {
      gfx_Line(128, y, 320, y);
   }
   if (jumperCollides && !firstTouch) {
      for (i = 0; i < 6; i++) {
         platforms[i].y += 4;
         if (platforms[i].y >= 235) {
            platforms[i].y = -15;
            platforms[i].x = randInt(130, 275);
         }
         gfx_TransparentSprite(greenPlatform, platforms[i].x, platforms[i].y);
      }
   } else if (!firstTouch) {
      for (i = 0; i < 6; i++) {
         gfx_TransparentSprite(greenPlatform, platforms[i].x, platforms[i].y);
      }
   }

}
void inGame(void) {
   uint8_t key = 0, i;
   guyX = 160;
   guyY = 80.0, velocityY = 0.5, gravity = 1.0;
   while (kb_ScanGroup(kb_group_6) != kb_Clear) {
      if (key & kb_Left && guyX > 128) {
         guyX -= 8;
      }
      if (key & kb_Right && guyX < 320 - 30) {
         guyX += 8;
      }
      if (guyY >= 215 &&firstTouch) {
         velocityY = -13.0;
         for (i = 0; i < 6; i++) {
            platforms[i].y = randInt(3, 200);
            platforms[i].x = randInt(130, 275);
            gfx_TransparentSprite(greenPlatform, platforms[i].x, platforms[i].y);
         }
         firstTouch = false;
      } else if(guyY >= 215) {
         velocityY = -13.0;
      }
      renderInGame();
      gfx_TransparentSprite(dLeft, guyX, guyY);
      gfx_SwapDraw();
      key = kb_ScanGroup(kb_group_7);
   }
   firstTouch = true;
}
So, I got all that blitting and gfx_spriting all done Very Happy Got a good speed increase, so that's awesome, but now...

gfx_CheckRectangleHotspot(). It asks for a master and a test. What are those? The test would be the location that you look for the hotspot right, but then what is the master? Thanks in advance Smile

Triple post get reported Just Joking

That looks amazing! Time to add a platform that lets you go up next, am I right? Razz
Yup, I actually pretty much have that complete, just gotta finish up an if statement when I get home.

Also project updates and no one posts after me Sad

Razz
This looks cool, Unicorn; keep it up! I always loved playing Doodle Jump.
Haha, thanks! I've gotten myself a bit stumped with stuff , but when I get home in a better work environment I will probably figure that out.

Edit: also wow this thread a needs another update...

Edit 2: And as promised, a more recent screenshot:
Talk to Mateo on how he did Oiram and semi-solids

You could also try detection that is above the platform to make the guy not clip.
  
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 2
» All times are GMT - 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