rotating stuff, having troubles...

Blitz3D Forums/Blitz3D Programming/rotating stuff, having troubles...

DREAM(Posted 2007) [#1]
Hi i am trying to get a jet to work out the back of a ship, a ship that can rotate 360 degrees, the ship is a graphic and works fine, i am trying to code the jet so i can customise the effects for it, making it longer particles etc.

here is the code what i am basing myjet on

Graphics 640,480

SetBuffer BackBuffer()

px=320:py=240

Repeat
	Cls
	If MouseDown(1) Or KeyHit(203) Or KeyDown(203)
		rot=(rot+1)Mod 360
	EndIf	
	If MouseDown(2) Or KeyHit(205) Or KeyDown(205)
		rot=(rot+359)Mod 360
	EndIf
	
	psp=8
	For i=0 To 4
		Color 255,200,150
		Rect px-6+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
		Rect px+7+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
	Next
	For i=0 To 6
		Color 255,200,0
		Rect px-4+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
		Rect px+5+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
	Next
	For i=0 To 8
		Color 255,100,0
		Rect px-2+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
		Rect px+3+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
	Next
	For i=0 To 12
		Color 255,0,0
		Rect px+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,3,6
	Next
		
		
	Text 10,10,"Use left and right cursor to rotate the jet stream."
	Flip	
Until KeyHit(1)

End


does anybody have an idea why the jet works for the up and down positions but not the left and right, it squishes it all into itself......not sure what i am doing wrong...

appreciate any pointers...


Stevie G(Posted 2007) [#2]
I replaced your rect with oval but like this?

Graphics 640,480

SetBuffer BackBuffer()

px=320:py=240

Repeat
	Cls
	If MouseDown(1) Or KeyHit(203) Or KeyDown(203)
		rot=(rot+1)Mod 360
	EndIf	
	If MouseDown(2) Or KeyHit(205) Or KeyDown(205)
		rot=(rot+359)Mod 360
	EndIf

	psp = 4.0	
	Nx# = Cos( rot ) : Ny# = Sin( rot )
	For i = 0 To 10
		r = 255
		g = ( 200 - i*20)
		b = ( 150 - i*15)
		rad = ( 15 - i )
		Color r, g, b
		Oval px - Nx * i * psp - rad , py - Ny * i * psp - rad, rad * 2 + 1, rad * 2 + 1
	Next
	
;	psp=8
;	For i=0 To 4
;		Color 255,200,150
;		Rect px-6+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
;		Rect px+7+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
;	Next
;	For i=0 To 6
;		Color 255,200,0
;		Rect px-4+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
;		Rect px+5+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
;	Next
;	For i=0 To 8
;		Color 255,100,0
;		Rect px-2+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
;		Rect px+3+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,2,6
;	Next
;	For i=0 To 12
;		Color 255,0,0
;		Rect px+Sin(rot+180)*i*psp/2,py+Cos(rot+180)*i*psp/2,3,6
;	Next
		
		
	Text 10,10,"Use left and right cursor to rotate the jet stream."
	Flip	
Until KeyHit(1)

End



I think you're better making a 2d particle system or having an anim image to represent the jet and it's animation in a similar way you would for your ship.

Stevie


DREAM(Posted 2007) [#3]
Thanks Stevie, sorry I took so long getting back. I will be doing this with a resolution of 1024,768 so it will look better, i will also start it the blue at zero and keep it there, then the white color looks yellow.

psp will be the thrust value so it will grow and shrink with speed.....some extra particles that fade off, i think it will do...

anyway here is a start......anybody else got any ideas..



Graphics 640,480

SetBuffer BackBuffer()

px=320:py=240:psp#=1

Repeat
	
	Cls
	If MouseDown(1) Or KeyHit(203) Or KeyDown(203)
		rot=(rot+5)Mod 360
	EndIf	
	If MouseDown(2) Or KeyHit(205) Or KeyDown(205)
		rot=(rot+355)Mod 360
	EndIf
	If KeyHit(200) Or KeyDown(200)
		psp=psp*1.1
		If psp>4 Then psp=4
	Else
		psp=psp*0.95
		If psp<1 Then psp=1
	EndIf	
	
	Nx# = Cos( rot ) : Ny# = Sin( rot )
	For i = 0 To 10
		r = 255
		g = ( 200 - i*20)
		;b = ( 50 - i*15)
		rad = ( 15 - i )
		Color r, g, b
		Oval px - Nx * i * psp - rad , py - Ny * i * psp - rad, rad * 2 + 1, rad * 2 + 1
	Next
	
	Text 10,10,"Use left and right cursor to rotate the jet stream."
	Text 10,20,"Use up cursor to use thrust."
	
	Flip	
Until KeyHit(1)

End