Jump to content
IGNORED

Sprite movement


retroshaun

Recommended Posts

OK... another probably stupid question.

 

I have a playfield set up in DPC+ with the screen res set with DF(0-3)FRACINC. All looks good. I have now added 3 sprites (player 0-2) and all I am doing is displaying them in a line across the screen and then I have a subroutine to increment their Y position so they effectively move down the screen, top to bottom.

 

The weird part is, if I start them anywhere on the visible screen, they don't move at all!! However if I start them off screen (for example at Y=200) then they move just as expected, starting right at the screen top and moving off the bottom then cycling to the top again.

 

What the hell?

Link to comment
Share on other sites

Best way to get help is to attach your code, it's hard to debug what you can't see.

 

I just saw your other post about "non-internet laptop". Do you have a way to transfer files between it and the computer you're using online? Floppy, USB stick, etc.

Edited by SpiceWare
  • Like 1
Link to comment
Share on other sites

No I was at work (long story on the internet thing!). At home now so all is well.

 

I think theres a fundamental thing I am simply not "getting" about DPC+. I am playing around now with this code, simply setting the default Y position in a var and assigning that to player0y with... "unexpected" results. I can cycle through 0, 10, 20 etc but when I hit, for example, 60... the sprite disappears completely. Most odd. How is the screen space addressed?

 

I have screen res and init set up as follows, and I admit to not really understanding the bank code at present, which may well be the problem!

 

set kernel DPC+

set smartbranching on

set optimization inlinerand

set kernel_options collision(playfield,player1)

set tv ntsc

 

goto StartInBank2 bank2

bank 2

temp1 = temp1

StartInBank2

 

DF0FRACINC = 32

DF1FRACINC = 32

DF2FRACINC = 32

DF3FRACINC = 32

DF4FRACINC = 64

 

And the main sprite update code is:

 

dim ey = 10

player0x = 30

 

main

gosub moveSprites

player0y = ey

drawscreen

goto main

 

moveSprites

ey = ey + 1

return

 

Like I said - its **very** basic at this point as I am only experimenting.

 

But as its set, this doesnt display the sprite. If I initially set player0x to, for example, 200... it works as expected.

Link to comment
Share on other sites

dim ey = 10

 

This isn't how you use dim. The item on the right of the equal sign should be a predefined bB variable, and the purpose of the command is to give that variable another name. (to make your code readable.)

 

For the code you wrote here, I'd expect bB to set the label "ey" to memory location 10, which is a TIA hardware register... screwy results will naturally follow.

 

Check out the dim section of the bB guide at Random Terrain's site for more info.

 

[edit] also worth mentioning that there's no reason you can't directly manipulated player0y; "player0y=player0y+1" works just fine.

Link to comment
Share on other sites

dim ey = 10

 

This isn't how you use dim. The item on the right of the equal sign should be a predefined bB variable, and the purpose of the command is to give that variable another name. (to make your code readable.)

 

For the code you wrote here, I'd expect bB to set the label "ey" to memory location 10, which is a TIA hardware register... screwy results will naturally follow.

 

Check out the dim section of the bB guide at Random Terrain's site for more info.

 

[edit] also worth mentioning that there's no reason you can't directly manipulated player0y; "player0y=player0y+1" works just fine.

 

 

Ahhh OK I got it - I was reading some stuff on DIM in another post and I guess what was written there was incorrect. That would explain it :)

 

Yes I realized I could increment player0y directly but I need to track the value for another use.

 

Thanks!

 

EDIT: All is working just fine now, thanks!

Edited by retroshaun
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...