Vincehood Posted January 17, 2017 Share Posted January 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
carlsson Posted January 17, 2017 Share Posted January 17, 2017 You use the SPRITE command to set your MOB to a different, already defined GRAM. The frequency most likely is set by using a counter which is updated after each WAIT, and then change the sprite and reset the counter once enough number of frames have passed. Quote Link to comment Share on other sites More sharing options...
Vincehood Posted January 17, 2017 Author Share Posted January 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
carlsson Posted January 17, 2017 Share Posted January 17, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted January 17, 2017 Share Posted January 17, 2017 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. 2 Quote Link to comment Share on other sites More sharing options...
Vincehood Posted January 17, 2017 Author Share Posted January 17, 2017 Oops you are right! Probably time to go to bed! Tack så mycket! /Vincent 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.