Jonny
Well-known member
I'm calling this sine wave movement but you could make modifications to manipulate the Y and/or X axis of your object however you want.
Disclaimer: This is NOT the best or most efficient way to do this. I'm not a programmer. It's just what I could come up with using the knowledge I currently have. If there are better ways please let me know. Also, this is more of a 'story so far' tutorial as I was hoping for a little help with a couple of things which I will mention at the end.
The Actual Tutorial...
A few things I'm working though now (any help appreciated)
Updating Object_y_hi somewhere else. The way things are set up at the moment, having the Y changes as part of the monster action means that I can't realistically have an animation which sucks. The changes become too slow. Try this out for yourself and you'll see what I mean. Atm I'm not sure how to go about that.
At the moment the position changes of the object are absolute values on the screen and not based on where the object is placed to start with on the Y axis. I want to change the Y value as increments starting with the position the object is in when loaded. I tried doing this but I must have been doing somehting wrong as it didn't work
I want to spawn the monster at the right cam edge, not sure if that's the correct term. Being a scrolling game I don't want to spawn at the screen edge on a timer as that wont make the object look like its constantly spawning from the right edge. How the gorilla guys spawn at the start of Ducktales is what I'm trying to do. I can do the timer but I don't know what to do to get the edge position as the screen is scrolling.
Thank you for any help in advance or improvements to the above. Enjoy.
Disclaimer: This is NOT the best or most efficient way to do this. I'm not a programmer. It's just what I could come up with using the knowledge I currently have. If there are better ways please let me know. Also, this is more of a 'story so far' tutorial as I was hoping for a little help with a couple of things which I will mention at the end.
The Actual Tutorial...
1. The monster action is a modification of the standard 'move left' script. First create a User Variable called starPos and start it at 255.
2. Make a new monster AI action with the following code and assign it in your script settings to an available AI Behavior slot...
Code:
;;; Y TABLE LOOP ;;;;;;;;;;;;;;;;;;;;;
INC starPos
LDY starPos
CPY #24 ;;; STEPS ;;;
BCC UpdateObjectPos
LDY #0
STY starPos
;;; UPDATE POSITION ;;;;;;;;;;;;;;;;;;
UpdateObjectPos:
LDA Yobject,y
STA Object_y_hi,x
;;; NORMAL MOVE LEFT STUFF ;;;;;;;;;;;
TXA
STA tempA
LDA #%00000110
TAY
LDA DirectionTableOrdered,y
STA tempB
LDA FacingTableOrdered,y
STA tempC
StartMoving tempA, tempB, #$00
ChangeFacingDirection tempA, tempC
3. Now we need a table. You have a few options for writing the values (where the object Y pos will be) either draw the sine wave by hand and work out the how many steps you want and and their positions, use excel or spreadsheet software to work out the places somehow, use this website I found or just be awesome at math. In this example we need the absolute values of where you want to object (i.e not based on where you actually placed the monster on the screen) more on that at the end.
4. Open up your ExtraTables.asm script or make one and assign it to Game \ Extra Tables in Project Settings \ Script Settings. Add your table values like this...
Code:
Yobject:
.db 95,101,108,113,117,119,120,119,117,113,108,101,95,89,83,77,73,71,70,71,73,77,83,89
This is the full wave, the peak and trough in other words. It's the same example as the .gif If you have more steps in your table make sure you change the steps number in the loop ( CPY #24 )
5. Lastly, setting up the monster. Give the object only 1 frame of animtion. The Y pos updates quickly because I'm not repeating the action but repeating when the animation ends. Repeating the action takes too long. This is one of the parts I need to figure out how to do better. The more animation frames you have the longer between steps. Basically, at the moment you can't animate the object AND move it in the sine wave. Improvements welcomed.
So... settings should be... lowish speed (say 15 ish), EndAction - Loop, EndAnimation - Repeat, Animation Speed - 1, Ignore Gravity.
That's it! Not very technical but it works.A few things I'm working though now (any help appreciated)
Updating Object_y_hi somewhere else. The way things are set up at the moment, having the Y changes as part of the monster action means that I can't realistically have an animation which sucks. The changes become too slow. Try this out for yourself and you'll see what I mean. Atm I'm not sure how to go about that.
At the moment the position changes of the object are absolute values on the screen and not based on where the object is placed to start with on the Y axis. I want to change the Y value as increments starting with the position the object is in when loaded. I tried doing this but I must have been doing somehting wrong as it didn't work
I want to spawn the monster at the right cam edge, not sure if that's the correct term. Being a scrolling game I don't want to spawn at the screen edge on a timer as that wont make the object look like its constantly spawning from the right edge. How the gorilla guys spawn at the start of Ducktales is what I'm trying to do. I can do the timer but I don't know what to do to get the edge position as the screen is scrolling.
Thank you for any help in advance or improvements to the above. Enjoy.