Sprites in MSX-C

Page 5/8
1 | 2 | 3 | 4 | | 6 | 7 | 8

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

24-04-2014, 09:45

Hi Jlemos, Thanks!

I will try your code and tweak it to fit within my code. That hex address is probably the first sprite.

I cleaned up my code yesterday and also got some things to work, moving the enemy sprites(need to write some sort of code for them to act like they are attacking of course) and built in some easy to use functions.
My main() consists out of some initialisations for the screen etc. and the first level loop, which can be exited by setting one condition to true to enter the next, it will eventually be a level loop within a overall game play loop, the second one will then contain the vert scroll and the player controlled sprite(s).
But now it is just 1 loop and two function calls, so a very clean main() and you then have 1 player sprite which is multi color and smooth moving freely and a multi color enemy sprite moving along a pre set path (i will built a randomiser in it, don't want it to get boring Wink )

Busy busy !

By Grauw

Ascended (8516)

Grauw's picture

24-04-2014, 13:41

Sounds fun Smile. The hex address is the memory address where the BIOS stores a copy of the value of the VDP’s first status register (updated every interrupt). See here.

By jlemos

Resident (56)

jlemos's picture

28-04-2014, 02:14

That's right!

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

05-05-2014, 09:49

jlemos wrote:

Use the below code in your C program.
char vdpvalue = 0;
char *STATFL = (char *)0xF3e7;
vdpvalue = *STATFL & 32;
if (vdpvalue > 0) {
/* Collision - Paint box red */
boxfill(0, 0, 32, 32, (char) 8, (char) 0);
}
else
{
/* Not Collision - Paint box white */
boxfill(0, 0, 32, 32, (char) 15, (char) 0);
}

Hi Jlemos,

Reading the status is easy indeed, tried it, works good, but, enemies crossing each other also give of the same result.
So is reading the status for all sprites only, or can it be identifiable per sprite?
the part that says
if (vdpvalue > 0)
is this 0 false and 1 is true, or is the output of the vdp higher and is this a complete pointerarray in which i can identify every single sprite and read it's status from it?

By jlemos

Resident (56)

jlemos's picture

06-05-2014, 03:29

Hi Wolverine_nl.

It's just the status of the fifth bit.

If this bit is turned on the collision has been detected.

Did some testing here and I noticed that sometimes the values ​​are strangers.
Must be because of the time of the VDP , but there's a lot I do not remember.

Try to use the below code to identify collision position.

int xPosCollision;
int yPosCollision;

vdpvalue = *STATFL & 32;
xPosCollision = ((int)(rdvsts((char) 4) & 1) * (int) 256) + (int)(rdvsts((char) 3));
yPosCollision = ((int)(rdvsts((char) 6) & 3) * (int) 256) + (int)(rdvsts((char) 5));

if (vdpvalue > 0)
{
...
/* Paint the collision area */
boxfill(xPosCollision, yPosCollision, xPosCollision + 8, yPosCollision + 8, (char) 4, (char) 0);

}

Look this document.

http://rs.gr8bit.ru/Documentation/V9938-programmers-guide.pdf

Best regards,

Julio Lemos

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

06-05-2014, 08:29

Thanks Julio, I am reading chapter 5.2 about the sprites collisions, certain status registers give coordinates to where the collision takes place, so I understand your code, going to see if i can make it work so that only the player and the bullets can collide with enemies and enemies not with each other. oO Big smile

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

06-05-2014, 10:33

Julio, that works, next I will code comparing the player sprite coordinates with the collision coordinates so compare the 3; player touches enemy(shield--) and shot touches enemy(score++) and enemy shot touches player(shield--).
Enemy touching enemy I can then rule out.
So a few Else Ifs would do the trick and I can connect those also to the shield bar of the player and the score as well, was already testing those with the other, and that worked fine already, only couldn't tell them apart.

By jlemos

Resident (56)

jlemos's picture

07-05-2014, 01:08

Very cool!

Big smile

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

13-05-2014, 10:56

Update:
I actually am focussing some attention to the shooting routine, it basically works, which is cool, but having some glitches.
Trying to turn off the bullet sprite when it reached the top of the screen, or should I wait for it untill it reaches the "blindzone" of screen5 which passes under 192px?

Also the trigger for the shooting button works, but a basic problem occurs, now you can actually hold the bullet in place while keeping the shot button pressed, when released it will fire off the bullet, so I am trying to find a way to do an automatic release of the gttrig value.

By jlemos

Resident (56)

jlemos's picture

15-05-2014, 03:30

Nice job.

Put some pictures about your game in somewhere and share here.

Best regards,

Julio Lemos

Page 5/8
1 | 2 | 3 | 4 | | 6 | 7 | 8