RE: A89: Programming Problem


[Prev][Next][Index][Thread]

RE: A89: Programming Problem




OOOPS I didn't know this question had already been responded to a million of
times sorry everyone.

-----Original Message-----
From: owner-assembly-89@lists.ticalc.org
[mailto:owner-assembly-89@lists.ticalc.org]On Behalf Of Nathaniel Gibson
Sent: Friday, June 09, 2000 10:25 AM
To: assembly-89@lists.ticalc.org
Subject: A89: Programming Problem



I wrote the program below just to see if I could get a ball to bounce
around the screen. Everything works except for when the ball hits the
left side of the screen: it looks like it hits 8 pixels too soon. Can
someone please tell me what I'm doing wrong? I think it has something
to do with the way Sprite16 processes the sprite, but I'm not sure.


Thanks in advance,

Nathaniel Gibson
ngibson@ptd.net


----------------------------CODE--------------------------
#define SAVE_SCREEN

#include <nostub.h>
#include <graph.h>
#include <system.h>
#include <sprites.h>

int _ti89;


int _main()
{
	static unsigned int ball [] = {0x3c, 0x7e, 0xff, 0xff, 0xff,
0xff, 0x7e, 0x3c};
	int key, x = 50, y = 50, xChange = 1, yChange = 1;
	void *kbq = kbd_queue ();
	long int j;

	ClrScr ();

	while (OSdequeue (&key, kbq))	{

		if ((x == 0) || (x == 143))	xChange *= -1;
		if ((y == 0) || (y == 91))	yChange *= -1;

		x += xChange;
		y += yChange;

		Sprite16(x, y, 8, ball, LCD_MEM, SPRT_XOR);
		for ( j = 0; j <= 50000; j++) ;
		Sprite16(x, y, 8, ball, LCD_MEM, SPRT_XOR);
	}

	return 0;
}




References: