0 Members and 4 Guests are viewing this topic.
Hmmm...interesting. I remember my raycaster flickering like crazy until I got double-buffering working.Are you doing anything special?
oooh I see, that explains why sprites won't flicker while the map is getting displayed. I assume they're drawn at the same time as the map, right?
I've got the buffering all figured out, but it seems like nmath.h is missing from the skeleton. When I tried to compile a program using line, I got an error saying nmath.h doesn't exist.
int abs(int x) {if (x<0) {x*=-1;}return x;}
char sprite[32]={15,15,15,0,0,15,15,15, 15,15, 0, 0,0, 0,15,15, 15, 0, 0, 0, 0, 0, 0,15, 0 , 0, 0, 0, 0, 0, 0, 0};
void sprite(char* scrbuf, char* sprite, int x, int y, int w, int h);
Unfortunately, apcalc, I read you unedited post, but now it's all sorted out, and I can play pong on my nspire.
#define abs(a) (a) > 0 ? (a) : -(a)
#include <os.h>#include "utils.h"asm(".string \"PRG\"\n");int main(void) { char marker[32]={15,15,15,0,0,15,15,15,15,15,0,0,0,0,15,15,15,0,0,0,0,0,0,15,0,0,0,0,0,0,0,0}; short int leftx,length,ycord,lengthchange; float spritepos; char* scrbuf = (char*) malloc(SCREEN_BYTES_SIZE); char* tempbuf = (char*) malloc(SCREEN_BYTES_SIZE); showSimpleDialogBox("TI-Nspire Tunnel","TI-Nspire Tunnel\nWritten in C by Danny Clark\n\nUse the arrow keys to control ship"); clearScreen(); leftx=120,length=120,lengthchange=1000,ycord=0; spritepos=180; clearBuf(scrbuf); for(ycord=0;ycord<SCREEN_HEIGHT;ycord++) { horizontalline(scrbuf,0,leftx,ycord,0); horizontalline(scrbuf,leftx+length,319,ycord,0);} sprite(scrbuf,marker,150,236,8,4); refresh(scrbuf); leftx=120; ycord=0; while (!isKeyPressed(KEY_NSPIRE_ESC)) { if (isKeyPressed(KEY_NSPIRE_LEFT)) { sprite(scrbuf,marker,spritepos,236,8,4); spritepos-=0.7; sprite(scrbuf,marker,spritepos,236,8,4);} if (isKeyPressed(KEY_NSPIRE_RIGHT)) { sprite(scrbuf,marker,spritepos,236,8,4); spritepos+=0.7; sprite(scrbuf,marker,spritepos,236,8,4);} sprite(scrbuf,marker,spritepos,236,8,4); lengthchange--; if (lengthchange==0) {length--;lengthchange=1000;} scrollScreen(scrbuf,tempbuf,1); horizontalline(scrbuf,0,leftx,ycord,0); horizontalline(scrbuf,leftx,leftx+length,ycord,15); horizontalline(scrbuf,leftx+length,319,ycord,0); sprite(scrbuf,marker,spritepos,236,8,4); refresh(scrbuf); //if (getPixel(spritepos-1,ycord-3)||getPixel(spritepos+8,ycord-3)) {free(scrbuf);free(tempbuf);return 0;} }free(scrbuf);free(tempbuf);return 0;}