Page 2 of 2

Re: Boing boing!

Posted: Tue Jan 09, 2018 2:31 pm
by dr beep
Gameplay is a nice feature with the dropping top.
This can become a 1K hires (or normal to play with ZXMORE ;-) )

Re: Boing boing!

Posted: Tue Jan 09, 2018 7:54 pm
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.

Re: Boing boing!

Posted: Tue Jan 09, 2018 9:27 pm
by dr beep
I mean normal hires screen with 6K buffer which will work on ZXMORE.

Re: Boing boing!

Posted: Wed Jan 10, 2018 8:47 pm
by Shaun_B
Cool, I look forward to playing it.

Thanks,

Shaun.

Re: Boing boing!

Posted: Wed Jan 24, 2018 10:32 pm
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.

Re: Boing boing!

Posted: Wed Feb 07, 2018 11:54 pm
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

Re: Boing boing!

Posted: Thu Feb 08, 2018 8:33 pm
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.