Realtime Flipping and SetScale

BlitzMax Forums/BlitzMax Beginners Area/Realtime Flipping and SetScale

FBEpyon(Posted 2005) [#1]
Well I have posted this help 4 times and no one has replyed can someone please help me with this :( I want to flip my images for a platformer im working on..


Function PlayerUpdate()

	Select PlayerState
		
		Case P_Idle
		
			If PlayerDir=P_Right Then 
				SetScale 1,1 '<------
				DrawImage(PlayerIdle,PlayerX,PlayerY,PlayerFrame)
			ElseIf PlayerDir=P_Left Then
				SetScale -1,1 '<------
				DrawImage(PlayerIdle,PlayerX,PlayerY,PlayerFrame)			
			EndIf
			
		Case P_Run
		
			If PlayerDir=P_Right Then 
				SetScale 1,1 '<------
				DrawImage(PlayerRun,PlayerX,PlayerY,PlayerFrame)
			ElseIf PlayerDir=P_Left Then
				SetScale -1,1 '<------
				DrawImage(PlayerRun,PlayerX,PlayerY,PlayerFrame)			
			EndIf
			
			PlayerWait = PlayerWait + 1
			If PlayerWait > 3 Then
				PlayerFrame = PlayerFrame + 1
				PlayerWait = 0
				If PlayerFrame > PlayerFMax Then PlayerFrame = 0
			EndIf
			
	EndSelect
	
	PlayerMove()

EndFunction



This doesn't seem to have any effect of my Flipping the image just goes away... Please help


(tu) ENAY(Posted 2005) [#2]
That should work ok. Setscale -1,1 works for me.

Do you need to check for left as well as right. Maybe you could do this.


			If PlayerDir=P_Right Then 
				SetScale 1,1 '<------
			Else
				SetScale -1,1 '<------
					
			EndIf
DrawImage(PlayerIdle,PlayerX,PlayerY,PlayerFrame)		



FBEpyon(Posted 2005) [#3]
Yep tried that also, for somereason the image just goes bye bye


(tu) ENAY(Posted 2005) [#4]
If I'm not mistaken when you scale by -1 it goes in reverse behind the actual image.
As in it doesn't scale from the center, perhaps you're missing the image off the edge of the screen or something.

Let me have a quick look.


FBEpyon(Posted 2005) [#5]
Hey ENAY if you want connect me on my MSN or AIM with FBEpyon and @msn.com for MSN

Yes you were correct you have to mid handle your images for this to work...

thanks


(tu) ENAY(Posted 2005) [#6]
Do you have any code I can have a play with?


(tu) ENAY(Posted 2005) [#7]
Try this:-

Strict

Graphics 800,600,16,1

Global moo = LoadImage("image.bmp")
MidHandleImage moo


While Not KeyHit(KEY_ESCAPE)
	Cls
	
	SetBlend ALPHABLEND
    	SetColor 255,255,255
    	SetAlpha 1.0
	SetScale 1,1
	DrawImage (moo,320,140)
	
	SetScale -1,1
	DrawImage (moo,320,240)
	
	SetScale 1,-1
	DrawImage (moo,320,340)
	
	SetScale -1,-1
	DrawImage (moo,320,440)
	
	FlushMem
	Flip
Wend

End


This works for me. If it doesn't work for you, then your machine is fwooked. :)