Movement problem

BlitzMax Forums/BlitzMax Programming/Movement problem

Rimmsy(Posted 2005) [#1]
Hi guys/gals,

I'm trying to create a pseudo camera zoom in a bmx game I'm making at the moment. I have a number of objects at certain coords and myself, at certain coords always displayed at the centre of the screen. I want to change the "zoom" of the "camera" to achieve an effect similar to this:

The problem with this example is, if you move anywhere, the effect is broken somehow. Any chance anyone knows how to fix it?




altitudems(Posted 2005) [#2]
Here is a redo of your code that works:




klepto2(Posted 2005) [#3]
As it seems, that you have only want to change the distance between the Items but not change their size, I have corrected your code:



Take a look to obj.update() method.


Rimmsy(Posted 2005) [#4]
That's fantastic! thank you both for taking the time to help me. I really appreciate it. You'll be in the credits.


Booticus(Posted 2005) [#5]
Thanks to ALL of you guys! I was looking to re-write code for EXACTLY this same routine. I always put it off, and here you guys have written up for all of us. THANKS!!!


tonyg(Posted 2005) [#6]
Very nice and easy to change into zoom-in/out...
Global objList:TList=CreateList()

Graphics 640,480,0,60

Global s#=1.0

For Local i=1 To 25
	Local o:obj=New obj
	o.x=Rand(-GraphicsWidth(),GraphicsWidth())
	o.y=Rand(-GraphicsHeight(),GraphicsHeight())
Next

Global youX#,youY#


While KeyHit(KEY_ESCAPE)=0
Cls	
	If KeyDown(KEY_NUMADD) Then s:+0.1
	If KeyDown(KEY_NUMSUBTRACT) Then s:-0.1
	If s<0.1 Then s=0.1
	If s>4 Then s=4	
	
	
	If KeyDown(KEY_UP) Then youY:-1.0*s
	If KeyDown(KEY_DOWN) Then youY:+1.0*s
	If KeyDown(KEY_LEFT) Then youX:-1.0*s
	If KeyDown(KEY_RIGHT) Then youX:+1.0*s
	
	
	updateObjs()

	SetColor 0,255,0
	DrawRect (GraphicsWidth()/2)-3,(GraphicsHeight()/2)-3,7*s,7*s
	
	SetColor 255,255,255;DrawText s,0,0
	DrawText "Press +/- on the numpad to zoom. Cursors to move",0,10
Flip
Wend
End


Type obj
	Field x,y
	
	Method New() ListAddLast(objList,Self); End Method
	Method update()
		Local dx=(youX*s)-GraphicsWidth()/2  'here you have forgotten the scalefactor
		Local dy=(youY*s)-GraphicsHeight()/2 'here you have forgotten the scalefactor
		SetScale 1,1
		SetColor 255,0,0
		DrawRect (x*s-3)-dx,(y*s-3)-dy,7*s,7*s
	End Method
End Type	

Function updateObjs()
	For Local i:obj=EachIn objList
		i.update()
	Next
End Function



Booticus(Posted 2005) [#7]
Thanks some more!!! ;)