Jump to content
IGNORED

How to animate a MOB?


Vincehood

Recommended Posts

Hello,

I am both trying to understand the theory and the practice behind MOB animation.

Once I have loaded the graphics in the GRAM (and assuming these graphics define different positions for a game character), how to go about animating it (and choosing the frequency of the animation).

I looked in some examples but I don't get it. Any hint?

Thanks

/Vincent

Link to comment
Share on other sites

OK...

I have tried the following below (with my 16x8 MOB) but I don't see any animation. Only the first GRAM is visible (the one in SPR00).

I have probably missed something...

Thanks

 

InfiniteLoop:
Spriteframe=0
SPRITE 0, X1 + VISIBLE,Y1 + DOUBLEY, SPR00 + (16*Spriteframe) + SPR_BLUE
WAIT
Spriteframe=Spriteframe+1:If SpriteFrame>7 then SpriteFrame=0
IF CONT1.UP THEN IF Y1>0 THEN Y1=Y1-1
IF CONT1.DOWN THEN IF Y1<104 THEN Y1=Y1+1
IF CONT1.LEFT THEN IF X1>0 THEN X1=X1-1
IF CONT1.RIGHT THEN IF X1<168 THEN X1=X1+1
IF CONT1.BUTTON THEN SOUND 0,100,15 ELSE SOUND 0,,0 ' beeper
GOTO InfiniteLoop

Link to comment
Share on other sites

You are resetting Spriteframe to 0 before you update the sprite. Try putting that one outside the loop.

 

To slow down the animation, try this:

 

Counter=0

Spriteframe=0

InfiniteLoop:

SPRITE 0, X1 + VISIBLE,Y1 + DOUBLEY, SPR00 + (16*Spriteframe) + SPR_BLUE

WAIT

Counter=Counter+1:If Counter>8 Then Counter=0:Spriteframe=Spriteframe+1:If Spriteframe>7 THEN Spriteframe=0

[... as above ...]

GOTO InfiniteLoop

  • Like 1
Link to comment
Share on other sites

Hi, Vincent,

 

There are two main ways to animate sprites. Unfortunately, other than low-level support for loading graphics, there is no built-in facility in IntyBASIC to animate sprites. That means that you must create your own loop and timing management.

 

The first kind is what is typically called "GRAM Cycling." Basically, you assign one GRAM card to a MOB and change the underlying picture in GRAM at regular intervals. This simulates the way that traditional key-frame animation works, such as cartoons. It works well, provided you are able to load GRAM at the top of each frame.

 

The second method trades CPU performance for memory space. It involves pre-loading all the images for all frames of an animation sequence into GRAM, and regularly changing the pointer in the MOB to reflect a new frame. The set up can be done once by loading everything into GRAM, and then your animation loop just needs to update the "A" register of the MOB periodically to point to the next card in the sequence. It does require the exclusive commitment of a chunk of GRAM.

 

Both of them are equally effective. Which one you choose depends on your program needs for speed or GRAM space.

 

dZ.

  • Like 2
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...