Boing boing!

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Boing boing!

Post by dr beep »

Gameplay is a nice feature with the dropping top.
This can become a 1K hires (or normal to play with ZXMORE ;-) )
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Boing boing!

Post by Shaun_B »

Normal with ZXMore? Do you mean that it starts too slow? That was intentional. I could make it faster from the start, but then that's not how the game should work in my head.

Thanks,

Shaun.
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Boing boing!

Post by dr beep »

I mean normal hires screen with 6K buffer which will work on ZXMORE.
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Boing boing!

Post by Shaun_B »

Cool, I look forward to playing it.

Thanks,

Shaun.
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Boing boing!

Post by Shaun_B »

Hi,

I just thought I'd update on how Bounce Redux works as some people have accused me of using 'clever maths' to make the ball travel in any other direction than 45 degrees.

I have an internal frame counter (note that the frame counter is only in the game world and may not resemble the actual ZX81 frames); every other frame updates the bat as well as checking the keyboard buffer.

This frame counter is also used to update the ball movement. This initially happens every 14th frame, and reduces as points are scored and the internal level counter increases.

I have an angle variable, which is set to 0 or 1. Essentially, what this is used for is to tell the bit of the ball update function to add the x position on every update (diagonal, 45 degrees), or every other update (diagonal, 22.5 degrees). As I'm only adding one each time to the x position depending on those conditions, the maths is not that clever.

I could apply the same logic to the y position, or add in another angle.

The interesting thing about using this methodology, rather than actual clever maths, is that I could use similar methodology for the attack patterns in games such as Missile Command (or at least a cost-reduced version thereof).

I will post code snippets if anyone is interested.

Regards,

Shaun.
JJH
Posts: 6
Joined: Sun Jan 28, 2018 4:15 pm

Re: Boing boing!

Post by JJH »

I'm chomping at the bit to play the game and code snippets are always interesting so please do post em up.
Well done and thank you
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Boing boing!

Post by Shaun_B »

As requested, here is a snippet of the moveBall() function from Bounce Redux:

Code: Select all

char directionX, directionY;
unsigned char x, y;
unsigned char lastX, lastY;
unsigned char angleX;
unsigned char ballDirection;

/**
 * Resets level variables
 *
 * @author	sbebbington
 * @date	07 Jan 2018
 * @version 1.0
 */
void resetLevel()
{
	x = 2 + (random % 4);
	y = 2;
	directionX = 1;
	directionY = 1;
	gameCounter = 0;
}

/**
 * Moves the ball around the play area
 *
 * @author	Shaun B
 * @date	06 Jab 2018
 * @version 1.0
 */
void moveBall()
{
	lastX = x;
	lastY = y;
	if((angleX % 2) == 0)
	{
		x += directionX;
		if(x < 2 || x > 29)
		{
			directionX = -directionX;
		}
	}
	y += directionY;
	if(y < 2 || y > 20)
	{
		directionY = -directionY;
	}
	if(x != lastX || y != lastY)
	{
		setText(clear, lastX, lastY, 0);
	}
	setText(ball, x, y, 0);
	angleX += ballDirection;
}
There is more logic than that (and yes, I should optimise it, something that I intend to do for the real cassette version).

So if angleX is always 2 then the ball will travel diagonally; if it is incremented by one each frame, it will travel at an approximate 22.5 degree angle (i.e., the ballDirection scalar is set to zero or one, and it adds it each update).

Regards,

Shaun.
Post Reply