English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. AMOS

 
 
Thread Tools
Old 07 June 2016, 08:31   #1
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Pieceing together different images to make an animation

I've seen some games use memory efficient tricks like making an animation by tacking certain images on to a main static image.

There's a section in one of the Amos manuals that describes something similar to this but doesn't really give examples so would this be achieved by having a second bob flash on the screen with one image while the main one runs it's animation but synced up co-ordinate wise so they appear as one? Or maybe something different involving some cleverly loaded tiles?

For example in the image below you can see that the body of the man during this punch is the same image and only the arm section is actually changing. (I know it's a Megadrive game but the point is the same!)



It's something I've noticed in games for years and been curious about so it'd be nice to know the Amos way of doing it.

Also regarding animation, is it possible to perhaps write your own animation tool? Or is there another available maybe via extension? Amal does it's job very well but I'm finding it a little restrictive in that it only seems to work with other Amal functions/commands instead of in tandem with Amos Basic. (This could just be my inexperience but regardless it's nice to know!)

Once again many thanks to all on the forum who've been a great help through my relentless questions which seem top have swamped this section. I feel I'm making leaps and bounds and I already have somewhat of a fully controllable and working player on screen with joystick activated animation which I thought would be impossible last week!
Brick Nash is offline  
Old 07 June 2016, 10:49   #2
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
You save a lot of memory by using the above method, and at times, also some speed. It's no more difficult than what you see in the picture:

Bob 1,player_x,player_y,1
Bob 2,player_x+player_width,player_y+20,4

You can certainly make your own animation tool, and it isn't that hard either. Usually you just rip away the game elements from your game, add mouse support and you have an editor. What you must decide on once you've done that is how to store your animations – should they be AMAL strings, some complex text format, some binary format, and so on? Furthermore, what needs to be stored in an animation sequence and what can be skipped? How do you put together several animations?
idrougge is offline  
Old 07 June 2016, 11:09   #3
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Quote:
Originally Posted by idrougge View Post
You save a lot of memory by using the above method, and at times, also some speed. It's no more difficult than what you see in the picture:

Bob 1,player_x,player_y,1
Bob 2,player_x+player_width,player_y+20,4

You can certainly make your own animation tool, and it isn't that hard either. Usually you just rip away the game elements from your game, add mouse support and you have an editor. What you must decide on once you've done that is how to store your animations – should they be AMAL strings, some complex text format, some binary format, and so on? Furthermore, what needs to be stored in an animation sequence and what can be skipped? How do you put together several animations?
Amazing, thanks for the info. I wasn't sure if I would have to make 2 bobs or do some trickery with the one. I take it it would just be done with simple Bob/Bob Off commands for the static image?

As for the animation that's cool to know for the future. Maybe I'm doing it wrong but I do find Amal to be powerful but also quite picky in terms of movement with the animation concerning transitioning from horizontal/vertical movement to diagonals and looping a movement to infinity with the joystick instead of a set number of steps then stop. Sometimes the way that it likes things to be ordered means a lot of duplicated code too where as if the sequence didn't matter it would be much better.

It doesn't matter as right now I'm just happy to get things running so it doesn't matter if it's particularly efficient just yet.

Thanks for the info, I'll give this a try right now!
Brick Nash is offline  
Old 07 June 2016, 11:16   #4
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
Quote:
Originally Posted by Brick Nash View Post
Also regarding animation, is it possible to perhaps write your own animation tool? Or is there another available maybe via extension? Amal does it's job very well but I'm finding it a little restrictive in that it only seems to work with other Amal functions/commands instead of in tandem with Amos Basic. (This could just be my inexperience but regardless it's nice to know!)
Using AMAL registers with the AMREG function will cure you of that misconception. See your thread on UltimateAmiga.co.uk for more info
Samurai_Crow is offline  
Old 07 June 2016, 12:22   #5
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Thanks I'll have a read of those today.

Quote:
Originally Posted by idrougge View Post

Bob 1,player_x,player_y,1
Bob 2,player_x+player_width,player_y+20,4
Just another quick question, when you say Bob 2, Player_x I take it that Player x is referring to Bob 1's current position on screen in order for Bob 2 to match it's position?

Obviously using just X and Y will be it's own co-ordinates so how would I actually bob 1's X and Y to tell bob 2?

Thanks again for all the help. I'm really quite chuffed with the progress I'm making thanks to everyone here.
Brick Nash is offline  
Old 07 June 2016, 14:50   #6
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Quote:
Originally Posted by Brick Nash View Post
Amazing, thanks for the info. I wasn't sure if I would have to make 2 bobs or do some trickery with the one. I take it it would just be done with simple Bob/Bob Off commands for the static image?
You do make two bobs, that's the whole point. You save memory by reusing the body as one bob and having the animation of the punch a smaller series of bobs.

Quote:
Originally Posted by Brick Nash
Maybe I'm doing it wrong but I do find Amal to be powerful but also quite picky in terms of movement with the animation concerning transitioning from horizontal/vertical movement to diagonals and looping a movement to infinity with the joystick instead of a set number of steps then stop. Sometimes the way that it likes things to be ordered means a lot of duplicated code too where as if the sequence didn't matter it would be much better.
I've never used AMAL because it seems so complicated, but it also seems very powerful. I do think that it's basically the smartest way to go if you can handle it because AMOS itself is so slow and AMAL is supposed to be very fast and geared to handle animations. AMAL should have no difficulty handling non-looping sequences either.

Quote:
Originally Posted by Brick Nash
Just another quick question, when you say Bob 2, Player_x I take it that Player x is referring to Bob 1's current position on screen in order for Bob 2 to match it's position?

Obviously using just X and Y will be it's own co-ordinates so how would I actually bob 1's X and Y to tell bob 2?
Exactly. What any game input loop usually does is to update the player's X and Y variables according to the joystick position pulled. You use those coordinates to test for collisions, whether the player is leaving the screen, if the screen should scroll and so on.
idrougge is offline  
Old 07 June 2016, 15:10   #7
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Quote:
Originally Posted by idrougge View Post
Exactly. What any game input loop usually does is to update the player's X and Y variables according to the joystick position pulled. You use those coordinates to test for collisions, whether the player is leaving the screen, if the screen should scroll and so on.
Thanks for all the info. Yes I get the concept but it's what to actually type into Bob 2's co-ordinates to make sure it appear at the exact same point as Bob 1.

If I type in -

Bob 2,X,Y,8,

It'll just call Bob 2's current position (which would be it's first position too) and not Bob 1's current position who could have moved across the screen by then.

I know this is wrong so take it as sort of pseudo code but something like

Bob 2, BOB1's X,BOB1's Y,8

Just something to type in those X and Y positions that will reference the current X and Y position of Bob 1. I tried making custom variables for both so I could switch in and out but it didn't seem to work.

In Game Maker I do it by putting an object's name and then .X or .Y such as ObjectEnemy.X and that returns the X value of the object it's name is attatched to so I can use it to sync movement between two objects with something like

For Player 1
X=ObjectEnemy.X
Y=ObjectEnemy.Y

So player 1's X & Y will now exactly follow ObjectEnemy.

I know it'll be done differently in Amos but the result is the same and it's just what to type in that's sort of baffling me.
Brick Nash is offline  
Old 07 June 2016, 15:33   #8
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Just store bob 1's X and Y coordinates in two variables. You can call them COCACOLA and PANTALOON if you wish, or just X and Y. Then you can use those variables for any bob.
idrougge is offline  
Old 07 June 2016, 16:11   #9
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Quote:
Originally Posted by idrougge View Post
Just store bob 1's X and Y coordinates in two variables. You can call them COCACOLA and PANTALOON if you wish, or just X and Y. Then you can use those variables for any bob.
I tried that but it didn't work. I created two custom X and X variables called POSX and POSY and tried to assign them to Bob 1's X and Y but it didn't work.

I don't think I'm doing it right. I initialised the variables in the variables section then I used them to initialise the bob before the main loop and then when Bob 2 is called to appear in the procedure I used them there but no joy. I made sure the variables were shared in the procedure as well

How exactly do you store Bob 1's X and Y coordinates in the custom variables?

It's can't be X=POSX because X would be individual to each bob wouldn't it and would just be calling on it's own co-ordinates and storing them?

Sorry I feel really stupid asking the same thing, it's my fault I know I'm slow and I do appreciate the patience.
Brick Nash is offline  
Old 07 June 2016, 17:16   #10
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
There is no magical X or Y thing. They're just variables like anything else. You can write BLAHBLAH instead of X or Y and the same thing will happen.
idrougge is offline  
Old 07 June 2016, 18:54   #11
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
If you set the hotspot of the BOB to the bottom-center of the character image, Amos will do the offsets for you.
Samurai_Crow is offline  
Old 07 June 2016, 19:46   #12
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Quote:
Originally Posted by idrougge View Post
There is no magical X or Y thing. They're just variables like anything else. You can write BLAHBLAH instead of X or Y and the same thing will happen.
I get that but how would they know which Bob to store from?

Right here's how I've done it -


I initialise my custom variables then Bob 1 with the custom variables Pre main loop

POSX=100
POSY=140

Bob1,POSX,POSY,1

I do the joystick inputs in the loop but I leave the blank spaces so it can change whatever info it needs to like position and image.
Bob1,,, etc,

Then I hit fire and that goes to a procedure outside the loop where I shared the POSX and POSY variables then when I call Bob 2 I use the variables as such which I assumed would give me the stored position of Bob 1 -

Bob 2,POSX,POSY,8

Bob 2 appears fine but if I move my player across the screen and press fire again Bob 2 appears in the place it was before and not where Bob 1 is now.

Sorry I know I'm a dummy and there's just something I'm not seeing. BTW I'm using 'Move X' to move the player with the joystick if that makes any difference?

Quote:
Originally Posted by Samurai_Crow View Post
If you set the hotspot of the BOB to the bottom-center of the character image, Amos will do the offsets for you.
That's handy to know thanks. I've got my own markers that I use for frame syncing which I use when importing. It's just a small green square at the top Left of each frame so if I get that in the top corner when I grab the images in then everything animates perfectly.
Brick Nash is offline  
Old 07 June 2016, 21:08   #13
jimwon2016
Registered User
 
Join Date: Apr 2016
Location: Portsmouth
Posts: 24
It sounds to me that you are seeking to create relationships between Bobs and variables or that you believe variables will change based on the movements of other bobs. This is not so.

In game engines like Game Maker you can define game objects with properties like .x or .y with behaviours like auto updating properties based on changes in the other game object properties. In Amos, none of that will happen.

The Bob instruction simply tells Amos to paste a predefined block of graphics onscreen at specified coordinates. You can use numbers, variables and expressions to define your coordinates.

Lets say our bobs are 16x16 and we want Bob 1 on top Bob 2:

X=100
Y=100

Do
If Jup(1)=True and Y>0 then Dec Y
Bob 1,X,Y,1
Bob 2,X,Y+16,2
Wait Vbl
Loop

...would accomplish this. Bob 1 is positioned at coordinates X,Y and Bob 2 is positioned at coordinates X,Y+16.

As you moved the joystick up, Bob 2 will always stick to the bottom of Bob 1. You would need to add more code for movement left, right and down.
jimwon2016 is offline  
Old 07 June 2016, 21:31   #14
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Quote:
Originally Posted by jimwon2016 View Post
It sounds to me that you are seeking to create relationships between Bobs and variables or that you believe variables will change based on the movements of other bobs. This is not so.

In game engines like Game Maker you can define game objects with properties like .x or .y with behaviours like auto updating properties based on changes in the other game object properties. In Amos, none of that will happen.

The Bob instruction simply tells Amos to paste a predefined block of graphics onscreen at specified coordinates. You can use numbers, variables and expressions to define your coordinates.

Lets say our bobs are 16x16 and we want Bob 1 on top Bob 2:

X=100
Y=100

Do
If Jup(1)=True and Y>0 then Dec Y
Bob 1,X,Y,1
Bob 2,X,Y+16,2
Wait Vbl
Loop

...would accomplish this. Bob 1 is positioned at coordinates X,Y and Bob 2 is positioned at coordinates X,Y+16.

As you moved the joystick up, Bob 2 will always stick to the bottom of Bob 1. You would need to add more code for movement left, right and down.
Ahhh I see. I thought that X and Y were there to store the individual Bob's co-ordinates and weren't universal.

I did try what you suggested above and a lot of other combinations too but Bob 2 still stays in the same place. I think it's because I'm using the Move X/Move Y commands to move my Bob 1 Amal animations and I don't think that STOS commands take into account stored co-ordinates as I think they work separately like Amal does.

Again I could be wrong but I have some proper reading to do courtesy of SamuraiCRow as I think that bridging that gap will help matters a lot.

Once again thank you for the mountains of help and patience everyone, it's very much appreciated!
Brick Nash is offline  
Old 07 June 2016, 21:39   #15
jimwon2016
Registered User
 
Join Date: Apr 2016
Location: Portsmouth
Posts: 24
Yes. As I said, there is no relationship there. Amal has it's own separate variables for tracking a Bobs X and Y. It will not make changes to a variable in Amos and you cannot define a relationship.

After moving a Bob with Amal, you need to pull its coordinates back into Amos using the Amal register functions. However, remember that Amal programs execute independantly of Amos so by the time Amos completes the instructions needed to do this, your Bob may have already moved to a new location.
jimwon2016 is offline  
Old 07 June 2016, 21:49   #16
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Quote:
Originally Posted by jimwon2016 View Post
Yes. As I said, there is no relationship there. Amal has it's own separate variables for tracking a Bobs X and Y. It will not make changes to a variable in Amos and you cannot define a relationship.

After moving a Bob with Amal, you need to pull its coordinates back into Amos using the Amal register functions. However, remember that Amal programs execute independantly of Amos so by the time Amos completes the instructions needed to do this, your Bob may have already moved to a new location.
Thanks for clarifying that. The second Bob is only needed when the first Bob is stationary and not 'while' in motion but I know what you mean in that it'll take time to recalculate where it was and then place it where it should be even if still.
Brick Nash is offline  
Old 07 June 2016, 21:53   #17
jimwon2016
Registered User
 
Join Date: Apr 2016
Location: Portsmouth
Posts: 24
That should be fine. If no Move commands are being executed by Amal when you process the instructions to grab coordinates for your second bob then you'll get an accurate result.
jimwon2016 is offline  
Old 08 June 2016, 16:03   #18
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
I'm just thinking....I'm using the STOS Move X/Move Y commands with my joystick inputs to move my Amal animations because I couldn't find a way to make the actual Amal Move command move continuously. It would always stop at the end set by the step parameter (in the STOS Move X/Y you just put an L at the end of the string to make it loop so it moves forever if the joystick is pushed in a direction) and there is nothing that I can see in the documentation about something similar for the Amal Move command.

Anyway, are the values in the STOS commands able to be stored in the AMAL registers and recalled with Amreg?

It just struck me that they may not be compatible.
Brick Nash is offline  
Old 08 June 2016, 18:42   #19
jimwon2016
Registered User
 
Join Date: Apr 2016
Location: Portsmouth
Posts: 24
I don't know on this one I'm afraid, you could test it yourself by pulling the X coord out of an Amal channel, running a Move X command then pulling the X coord again and see if it's changed.
jimwon2016 is offline  
Old 08 June 2016, 21:28   #20
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
I dont think Amal is faster unless your using 68020+ I also dont think Amos is much slower than other options once compiled - Amal makes things simplar writing a complex movement routine handling many Bobs is much more complicated than using Amal - the Amiga is "slow" compared to?....... consoles? and there many sprites this has been said and done so many times the amiga and the scene are borring - show me a demo of blitz running faster or any other similar language.

Last edited by Retro1234; 08 June 2016 at 21:33.
Retro1234 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
animation software moijk support.Apps 3 25 March 2013 17:36
Is it possible to get this demo/animation? TTD request.Demos 2 22 October 2011 19:04
Boing Animation Fingerlickin_B request.Demos 8 27 February 2009 14:45
How to make iBrowse load images to Fast RAM? Fingerlickin_B support.Apps 2 23 February 2009 06:11
Name of animation? Drake1009 Retrogaming General Discussion 7 10 December 2001 13:00

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:36.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.51467 seconds with 15 queries