Sprites in MSX-C

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

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

17-04-2014, 13:47

okay that's clear enough, it would only be for my visual/logical overview convenience to seperate stuff, thx! Smile

By Manuel

Ascended (15835)

Manuel's picture

17-04-2014, 15:53

Separating stuff should be done in such a way, that you don't need to include ".c" files. Only header files.

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

18-04-2014, 23:04

ok.
coding now the multicolor sprite movement, gtstck is pretty much the same everywhere, but to get the y axis to react om the gtstck(0) value of 1 or another key/joy direction isnt really working out.
I am using a for loop:

if (gtstck(keyport) == 0) 
		{
			putspr(p,pllocx,pllocy,logop,t); 			
		}
	else if (gtstck(keyport) == 1)
		{
			for (i = 0;gtstck(keyport) > 0; i++) 
				{
					putspr(p,pllocx,pllocy+i,logop,t); /* putspr(plane,x,y,logop,pat nr); */
				}
		}

not really a good solution (this example is for going up.)

By hit9918

Prophet (2868)

hit9918's picture

19-04-2014, 02:42

It looks like it could be replaced with

stck = gtstck(keyport); //call this only one time and store in variable, save cpu time
if (stck == 1)
{
	pllocy = pllocy + 1
}
putspr(p,pllocx,pllocy,logop,t); /* putspr(plane,x,y,logop,pat nr); */

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

19-04-2014, 13:06

@hit9918
I did try that (except the stck=gtstck part), but that just shows a sprite, pressing the up key wont move it one bit (lol)
So thats why i was going for a FOR loop, so inclemently add a value could plus the y axis by not only 1, but when keeping the key pressed, keeps on counting.
I will try something else and post it here.

By hit9918

Prophet (2868)

hit9918's picture

19-04-2014, 13:56

Remove things till something happens.
Removing the stick part:

while(1)
{
	pllocy = pllocy + 1
	putspr(p,pllocx,pllocy,logop,t); /* putspr(plane,x,y,logop,pat nr); */
}

Now the sprite should run wild.

Another test would be to put the value returned by gtstck(keyport); to bordercolor.
Then wiggle the stick and see whether something happens.
Testing things isolated.

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

19-04-2014, 14:27

good idea :-) Will do that, thanks!

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

21-04-2014, 20:37

I got it to work, only now my multicolorsprite shows not all colors.
Plus i see the speed of the sprite is wayy too fast.
I was trying the following to slow it down:

x = (x + 1) % 40;

But that doesnt work for some reason :/

By Creepy

Champion (332)

Creepy's picture

21-04-2014, 20:50

That does not slow it down, but keeps x between 0 and 39 (inclusive). Try to sync the code to VBLANK to slow it down. Or just use a big for loop to create a slow down if you want a quick test.

By Wolverine_nl

Paragon (1046)

Wolverine_nl's picture

22-04-2014, 09:34

VBLANK is a bios call? Or is it a framething, not familiar with it. Is there documentation on it somewhere?
I was actually thinking on using the systemclock, cause that would mean the playingspeed would be more the same on each machine (MSX2 and higher models), or is using VBLANK doing a similair thing?
Cause a for loop would be different in performance on a faster machine.

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