Jump to content
IGNORED

Animating a sprite


endrien

Recommended Posts

So I took a look at the snippet, and I'm still trying to figure out how it works, and how to apply it to a button press such as right/left.

Could someone help me?

 

Edit: I just realized there is a snippet on moving an animated sprite, though I would still like a bit of an explanation as to how this code works.

 

main
 COLUBK=$02
 COLUP1=$28

y=y+1

 if y=10 then player1: 
       011100
       011000
       011000
       100000
       011000
       %01011111
       %01100100
       010000
       011000
       111100
       011000
end
if y=20 then player1:
       %01000011
       %01100010
       110110
       011100
       101000
       111100
       100100
       010000
       011000
       111100
       011000
end
if y=30 then player1:
       011100
       011000
       011000
       100000
       %01011010
       %01111100
       100100
       010000
       011000
       111100
       011000
end

if y>30 then y=0 

player1x=50:player1y=50

drawscreen

goto main

Edited by endrien
Link to comment
Share on other sites

I'm almost done with the first draft of my example program. It has an animated sprite in 8 directions, you can shoot a missile in 8 directions, it has collision detection with playfield pixels, and a couple of sound effects. I'm almost done adding the comments (feels like I added a billion of them). I should be done in a couple of hours and I'll create a new thread about it. I kind of like how it's going, so I might eventually turn the example program into a game.

Link to comment
Share on other sites

I'm almost done with the first draft of my example program. It has an animated sprite in 8 directions, you can shoot a missile in 8 directions, it has collision detection with playfield pixels, and a couple of sound effects. I'm almost done adding the comments (feels like I added a billion of them). I should be done in a couple of hours and I'll create a new thread about it. I kind of like how it's going, so I might eventually turn the example program into a game.

 

Perfect man, that is exactly what I'm looking for! The snippets are nice, but confusing in nature because you are following them and they teach you different ways to do things as you go through them and then they combine multiple ones and change the way they did it before. Completely confusing.

I did manage to get a decent titlescreen and a player that is animated(The move+animation snippet has the character always animated...Useless). After missiles etc I need to figure how to add playfield obstacles, enemies and powerups :).

 

I must thank you though, as you've been greatly helpful in my learning thus far.

Edited by endrien
Link to comment
Share on other sites

main
rem Set the background color
 COLUBK=$02
rem Set the player color.  Note this must be done after EVERY drawscreen.  
 COLUP1=$28

rem Increment or decrement our counter by 1 using the joystick
rem Note we didn't have to dim this variable as we used its
rem original name y
if joy0right then y = y + 1
if joy0left then y = y - 1

rem If user goes past the max animation timer amount then reset counter.
rem note that y becomes 255 after subtracting from 0 so only one IF statement
rem is needed to check for over and under limits.
if y>30 then y=0 

rem When the counter reaches 10 then
rem change to this sprite image.
rem Note that by waiting 10 loops it adds an
rem appropriate duration for each animation step.
 if y=10 then player1: 
       011100
       011000
       011000
       100000
       011000
       %01011111
       %01100100
       010000
       011000
       111100
       011000
end
rem When the counter reaches 20 then
rem change to this sprite image.
if y=20 then player1:
       %01000011
       %01100010
       110110
       011100
       101000
       111100
       100100
       010000
       011000
       111100
       011000
end
rem When the counter reaches 30 then
rem change to this sprite image.
if y=30 then player1:
       011100
       011000
       011000
       100000
       %01011010
       %01111100
       100100
       010000
       011000
       111100
       011000
end

rem Reset counter so animation loop can start over
if y>30 then y=0 

rem Center player position on screen
player1x=50:player1y=50

rem Refresh the screen so end user can see animation
drawscreen

rem Got up.  Went to work.  Going home to start over. 
goto main

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

I think the examples will be great, but they need to be broken down into smaller chunks. Don't do animation, joystick, sound, and well a full game in one.

 

I am working on an example of my own, but had some troubles. It's been awhile since I did what I am trying to explain, and I was doing it at work so that was taking away my concentration.

Link to comment
Share on other sites

I think the examples will be great, but they need to be broken down into smaller chunks. Don't do animation, joystick, sound, and well a full game in one.

 

I am working on an example of my own, but had some troubles. It's been awhile since I did what I am trying to explain, and I was doing it at work so that was taking away my concentration.

I plan to make little example programs too. I'll also have larger example programs like the one I'm trying to finish up. This larger program is helping me figure out some things, so my smaller example programs should be better than they would have been.

Link to comment
Share on other sites

I think the examples will be great, but they need to be broken down into smaller chunks. Don't do animation, joystick, sound, and well a full game in one.

 

I am working on an example of my own, but had some troubles. It's been awhile since I did what I am trying to explain, and I was doing it at work so that was taking away my concentration.

I plan to make little example programs too. I'll also have larger example programs like the one I'm trying to finish up. This larger program is helping me figure out some things, so my smaller example programs should be better than they would have been.

 

I'd prefer the larger example, that's my problem with the current snippets. With good comments and full code I could simply look at how you did it and put it together and then use that towards my own game.

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...