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:
Help would be greatly appreciated
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