little help
Home › Forums › TimelineFX Module › little help
- This topic has 4 replies, 2 voices, and was last updated 15 years ago by Day.
-
AuthorPosts
-
November 12, 2009 at 2:14 pm #3131
DayParticipantok so either im very tired or i just cant seem to figure out how to get the thrust effect to go behind the ship and stay with it as it moves left or right.
cut down code any help? lol im new to 2D stuff
im using the simple thrust from the shootem up eff in this
[attachment=0:1o4ootsp]Spacestuff.rar[/attachment:1o4ootsp]
November 12, 2009 at 9:59 pm #3541
DayParticipantok i have made some head way into this i can now position my effect to were i want it but how do i get it to update its position as the ship moves?
to mutch of the code is oop and makes it hard for newer people to read so maybe add some demos etc that dont require as mutch oop.
makes them easy to follow then as the only demo with sprites is vaders and thats way to harsh to figure out if your new.
Damian
Import rigz.timelinefx
Import rigz.tweener
SetGraphicsDriver GLMax2DDriver()
Graphics 1280,800,16,0,1
HideMouse
'
Effects Libarys
Local MyEffectsLib:tlEffectsLibrary = LoadEffects("efx/Effects.eff") ' change to shoot em up eff
Local MyEffect:tlEffect = MyEffectsLib.GetEffect("PlayerThruster") ' simple thruster
Local MyParticleManager:tlParticleManager = CreateParticleManager()
MyParticleManager.SetOrigin(GraphicsWidth()/2,GraphicsHeight()/2)
'
Player
PlayerShip:TPlayerShip = New TPlayerShip
PlayerShip.Image:TImage = LoadImage( "GFX/PlayerShip65.bmp" ) ' Error 001
'
Enemy Normal
'
PreLoop Setup
MyParticleManager.SetScreenSize(GraphicsWidth(), GraphicsHeight())
SetUpdateFrequency(30)
Local Tweener:tTweener = New tTweener.Create(30)
Local TempEffect:tlEffect=CopyEffect(MyEffect, MyParticleManager)
TempEffect.SetX(640)
TempEffect.SetY(759)
MyParticleManager.AddEffect(TempEffect)
'
Main Loop
While Not KeyDown(KEY_ESCAPE)
Cls
Tweener.Update()
For Local Ticks:Int = 1 To Tweener.FrameTicks
Tweener.UpdateExecutionTime()
MyParticleManager.Update()
Next
MyParticleManager.DrawParticles(Tweener.Tween)
PlayerShip.UpdateState()
PlayerShip.DrawSelf()
Flip
Wend
End
'
Types
Type TPlayerShip
Field X:Int = 600
Field Y:Int = 702
Field Speed:Int = 3
Field Lives:Int = 3
Field Weapon:Int = 1
Field ShieldState:Int = 0
Field ShieldEnergy:Int = 0
Field Image:TImage
Function Create:TPlayerShip(File:String, XStart:Int, YStart:Int )
Local Ship:TPlayerShip = New TPlayerShip
Ship.X = XStart
Ship.Y = YStart
Ship.Image = LoadImage( LoadBank(File) )
If Ship.Image = Null
Notify "Error: 001 Unable to load gfx"
End
EndIf
Return Ship
End Function
Method UpdateState()
If KeyDown( KEY_LEFT )
X:- Speed
EndIf
If KeyDown( KEY_RIGHT )
X:+ Speed
EndIf
If X < 0 Then X = 0
If X > 1195 Then X = 1195
End Method
Method DrawSelf()
DrawImage Image, X, Y
End Method
End TypeNovember 12, 2009 at 10:18 pm #3542
imported_peterigzParticipantHello, I changed quite a few things which I marked with remarks. The main thing was to put a new field in the ship type to contain the thruster effect. You can then use this to update its position in the UpdateState Method. I also changed the timing code a bit. Logic updates should go in the for..next loop and rendering should happen outside. Take a look at this example: http://www.rigzsoft.co.uk/index.php?option=com_content&view=article&id=25 for a basic timing example using the tweener mod. If you understand that then you can add tweening to you spaceship as well.
It is is very OO and can be tricky to get used to but very much worth it in the end. I recommend the basic game tutorial here on this site: http://www.rigzsoft.co.uk/index.php?option=com_content&view=category&id=11&Itemid=11 and I also wrote another tutorial about making an asteroids game that actually uses the thruster effect. I wrote that for the Blitzmax coder magazine but I’ll attach a copy here in this thread if you missed it, I’ll just go dig it out…
November 12, 2009 at 10:26 pm #3543
imported_peterigzParticipantHere is the Asteroids tutorial attached, and all the source code for it is here: http://www.rigzsoft.co.uk/files/asteroidstutorialpart3.zip
November 13, 2009 at 12:32 pm #3544
DayParticipantgonna check it over now thanx
-
AuthorPosts
You must be logged in to reply to this topic.