Wait…Wait…Stop.

It seems I’ve been living a lie. Things seem fine, but that is a falsehood.

I have been ignoring the text output for error messages and just running the TAP and things seem fine, but they are not. Somehow it must be running the last good version which tests none of my changes. Arrrgh! I noticed it when on closing out the command prompt and rebuilding I started getting errors and looking at the code with a more critical eye, I can see the issue standing out like a sore thumb. This is the problem, in the player_handler() function, there are variables that are called without being passed onto the function, yet it compiled without even a hiccup. I will have to re-examining the batch file and my source code again. Silly Rabbit, coding is for smarter people.

Time to reset the code, thank goodness I kinda keep a backup, kinda.

I have made a small change to my fase.bat file.

cls
call z88dkenv.bat
echo #######################
echo ## ready to compiled ##
echo #######################
zcc +zx -zorg=32772 -O3 -vn main.c -o build\main.bin -lndos
echo ######################################
echo ##File main.bin compiled from main.c##
echo ######################################
echo ################
echo ##compiled....##
echo ################
pause

This is to clear the screen and pause just after the compile so I will look at the screen more closely. Eventually I will remove those, but for now, I need to play closer attention.

I am now also moving the player code back to the main look, basically a reset of the work I had done. I will eventually get it into a header, but not now.

Next few pages will show the main character movement code

 

Here is the movement on the X axis

//calculation of player X axis / horizontal
vx += ax;
x += vx;
if( vx + 8 >> 3 )
{
    ax = -vx >> 3;
}
else
{
    ax = vx = 0;
}
if( (unsigned int)x > scrw << 12 ) { if( vx > 0 )
{
//screen right
if( mapx < mapw - 2 )
{
    x = scrw << 12;
}
}
//screen left
if( vx < 0 )
{
if( mapx < 8)
{
x = 0 << 12;
}
}
}

Here is the movement on the Y axis

//calculation of player Y axis / vertical
vy += ay;
y += vy;
//vertical movement
if( vy + 8 >> 3 )
{
ay = -vy >> 3;
}
else
{
ay = vy = 0;
}
if( (unsigned int)y > scrh << 12 ) { if( vy > 0 )
{
if( mapy < maph - 1 )
{
y= scrh << 12;
vy= 0;
}
}
//screen left
if( vy < 0 )
{
if( mapy < 8)
{
y = 0;
}
}
}

Our sprite calling routine.

sprites[0].x = x >> 8;
sprites[0].y = y >> 8;

Finally, moving the character around.

// motion of the protagonist
if( Input() & 0x01 ) // P - go right
{
ax = vx < maxvx ? 40 : 0; } if( Input() & 0x02 ) // O - go left { ax = vx > -maxvx ? -40 : 0;
}
//now we have down doing the same as up for testing
if( Input() & 0x04 )// A go down
{
ay = (vy < maxvy) ? 40 : 1; } if( Input() & 0x08 )// Q go up { ay = (vy > -maxvy) ? -40 : -1;
}
if( Input() & 0x10 && !spacepressed && num_bullets
{ // Space (FIRE)
Sound(EFFX, 0);
bullets[num_bullets].x= sprites[0].x;
bullets[num_bullets].y= sprites[0].y;
i= Input() & 0x0f;
dirbul[num_bullets]= i ? i : 1;
num_bullets++;
}
spacepressed= Input() & 0x10;

Finally, the test of the code runs fine. The entire point was to have the main character not be able to leave the screen and not have the character wrap around to the other side. The play action on this game is within a single screen. Touching the walls will be deadly to your character.

In fact, that should be my next task, killing the character when he touches the 4 walls.

After that, I want to create simple mazes aka Berzerker.

Advertisements

Author: andydansby

I'm a hobbyist coder working with the ZX Spectrum. Living in New York state near the Syracuse area. I grew up in Virgina. The first computer my parents bought for me was a Timex Sinclair 2068.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s