English Amiga Board


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

 
 
Thread Tools
Old 01 June 2016, 10:35   #1
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Amal animation & HREV with joystick commands

Hi folks apologies for the more in depth post but I thought it time to actually post what I'm typing in. There may be a few mistakes as I can't get clipboard sharing to work so I had to copy the code by hand!)

I'm trying out moving my Bob with a joystick now and so far so good but I'm wondering how to go about using the joystick commands like Jup, Jright etc and using them in conjunction with my Amal animation so that it plays while the joystick is activated plus the HREV command to flip the image if Jleft is activated

I can get the animation running but no joystick movement if I place the bob definition and Amal command above the joystick input loop or I can get the joystick to work but no animation (or flipping) when I put the bob definition and Amal command within the joystick loop.


All the joystick commands are in there but here's some examples using just Jleft:

The code below means I can move but the animation doesn't play -

Code:
SX=SX-1

SX=160 : SY=100 : GUY=1

DO
bob 1, SX, SY, GUY
If Jleft(1) and SX>0 Then SX=SX-1

Wait VBL
Loop

Amal 1 "Anim 0, (1,8) etc............."
Amal On
The code below means the animation plays but the joystick won't move the bob -

Code:
SX=SX-1

SX=160 : SY=100 : GUY=1

bob 1, SX, SY, GUY
Amal 1 "Anim 0, (1,8) etc............."
Amal On

DO

If Jleft(1) and SX>0 Then SX=SX-1

Wait VBL
Loop
I've tried placing the Amal commands in a variety of places that seemed sensible including putting the bob definition and Amal command in the lop and putting 'Amal on' after the joystick commands using the colon ( : ) but so far nothing seems to work.

Thanks for the tolerance folks, manuals are a little hard when you have a learning difficulty and sometimes things don't sink in or click right away so I appreciate the tolerance.
Brick Nash is offline  
Old 01 June 2016, 15:47   #2
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
I've never used AMAL, but shouldn't your JLeft action just trigger a certain AMAL sequence to move one or two pixels?
idrougge is offline  
Old 01 June 2016, 18:29   #3
jimwon2016
Registered User
 
Join Date: Apr 2016
Location: Portsmouth
Posts: 24
In your first code snippet, place your AMAL commands before your loop and don't change anything else.
jimwon2016 is offline  
Old 01 June 2016, 20:02   #4
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Quote:
Originally Posted by Brick Nash View Post

The code below means the animation plays but the joystick won't move the bob -

Code:
SX=SX-1

SX=160 : SY=100 : GUY=1

bob 1, SX, SY, GUY
Channel 1 to Bob 1:Rem assigns Channel 1 to Bob 1 (Gets confusing with later Bobs/Sprites if you forget)
Amal 1 "Anim 0, (1,8) etc............."
Amal On

DO

If Jleft(1) and SX>0 Then SX=SX-1
bob 1, SX, SY, GUY:Rem Never forget to Re-Display your Bob if Using BASIC to Display/Update it.
Wait VBL
Loop
I think that should be a start.

I wouldn't bother with the REV commands unless you are short of ram as they cause no end of collision detection and "HOT SPOT" problems, It's easier to have a flipped copy of the bob in the sprite bank (unless the bob is very large of course).

Last edited by volvo_0ne; 01 June 2016 at 21:59.
volvo_0ne is offline  
Old 01 June 2016, 23:46   #5
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
think about the order these commands execute in.

in the first example the line "Amal 1..." never gets executed because the loop is looping forever.

in the second example the line "bob 1, SX, SY, GUY" only gets called before the start of the loop, so when SX is changed it doesn't update the bob's position to the new SX.

tbh i wouldn't mix AMAL with normal AMOS programming, it can only lead to confusion. Personally i never found AMAL very useful for in-game animation.
Mrs Beanbag is offline  
Old 02 June 2016, 00:16   #6
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Quote:
Originally Posted by Mrs Beanbag View Post
think about the order these commands execute in.

in the first example the line "Amal 1..." never gets executed because the loop is looping forever.

in the second example the line "bob 1, SX, SY, GUY" only gets called before the start of the loop, so when SX is changed it doesn't update the bob's position to the new SX.

tbh i wouldn't mix AMAL with normal AMOS programming, it can only lead to confusion. Personally i never found AMAL very useful for in-game animation.
Personally I disagree.

IF you setup & leave AMAL to get on with the movement of "enemies" in a game, and then control the Player Bob/Sprite movements, you only have Collision detection between Player & Enemy to contend with from AMOS.

Obviously this depends on the game type, but USUALLY that's all you need for Lost lives or energy loss etc

If the Enemy/Player interaction is more complex, then of course it's going to be more difficult.

AMAL is powerful, and fast.

I find that If you detect collisions between ONE player & an AMAL object, it's fast & reliable.

The problem begins when you attempt to influence AMAL objects from each other, because the language isn't really designed for that.IMHO

(although it can be done, but not in interrupts, which kinda goes back to the beginning)


So... Animate & Move ENEMIES in AMAL but keep a close eye on your Player with AMOS(BASIC) which is MUCH easier to manipulate in realtime.

Again I stress this is dependent on the game type.
volvo_0ne is offline  
Old 02 June 2016, 09:07   #7
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Excellent info as always folks, thanks! I managed to get a the Hrev working and all the hot spots are right now too but I'll ill maybe try to animate with Amos basic today and see what happens.

It's strange to try and think of Amal and Amos as two separate languages since I've been using them both pretty much from the off in the same environment but it's certainly something I'll keep in mind in the future.

Just a small couple of addition questions that I noticed that I'd like to ask - When using 'If' and 'Then' statements I know I can add other references on to 'Then by using the : but can they be continued on to another line, perhaps by wrapping in parenthesis or something similar (or is that getting a bit too modern?)

For example if I were to type -

If Jup(1) Then Jump : something else ...
....but continue onto this next line.

I've no need for it just yet but it would just be for code tidiness.

Also can I reference a bob and it's current state in an If statement?

For example I noticed with my joystick controls (when it worked) that all the directions worked fine but if I was facing left (and the bob was flipped with Hrev) but then I pushed up then the bob would flip back again because that's what I have for the Jup(1) position.

If I could add a second condition to tell Amos IF Jup(1) is activated AND the bob is currently in the flipped (Hrev) then to display the bob as flipped and obviously a similar one for if the bob is facing right.

I tried - If Jup(1) and bob 1,SX,SY, Hrev(GUY) then bob 1,SX,SY,Hrev(GUY)

Obviously that didn't work becasue it can't see a command as a reference so is there a way to do that becasue 'If' statements are pretty useful although again I'm not sure how it would work with animation but it'd be good to know if it's at least possible.

Once again, many thanks from an annoying noob!
Brick Nash is offline  
Old 02 June 2016, 15:01   #8
jimwon2016
Registered User
 
Join Date: Apr 2016
Location: Portsmouth
Posts: 24
In answer to your question about using multiple lines for an If statement, I suggest you do this instead:

If CONDITION=True
Do this
Do that
Do another thing
Now this
End If

Having more than one instruction on a single line executes slower than having a list of instructions.

Regarding Hrev, I would probably just have a variable to keep track of the flipped status of the object and then check the variable....

If JUp(1)=True
If ISBOBFLIPPED=True
Bob 1,SX,SY,HRev(GUY)
Else
Bob 1,SX,SY,GUY
End If
End If
jimwon2016 is offline  
Old 02 June 2016, 18:32   #9
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
Quote:
Originally Posted by jimwon2016 View Post
In answer to your question about using multiple lines for an If statement, I suggest you do this instead:

If CONDITION=True
Do this
Do that
Do another thing
Now this
End If

Having more than one instruction on a single line executes slower than having a list of instructions.

Regarding Hrev, I would probably just have a variable to keep track of the flipped status of the object and then check the variable....

If JUp(1)=True
If ISBOBFLIPPED=True
Bob 1,SX,SY,HRev(GUY)
Else
Bob 1,SX,SY,GUY
End If
End If
Wonderful thank you! I'm much more at home using If statements. Got a nice little joystick routine up and running now and great idea on the custom variable. Makes things so flexible.
Brick Nash 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
Animating explosion without amal aszu Coders. AMOS 13 17 March 2016 23:33
More AMAL headaches.... volvo_0ne Coders. AMOS 0 23 February 2016 00:17
Want to buy a Tomahawk joystick or trade with an tac 2 joystick black box&manual astraldimension MarketPlace 5 19 March 2015 10:55
jAMAL - AMOS BASIC AMAL reimplementation in Java! Mequa News 26 31 January 2012 02:12
Flink v2.2 & v2.3 joystick problem Retroplay project.WHDLoad 0 06 June 2009 15:15

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 17:42.

Top

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