I need a simple example~

BlitzPlus Forums/BlitzPlus Programming/I need a simple example~

Apollonius(Posted 2003) [#1]
I need a simple example on displaying and image and making it move up,down,left,right with the arrow keys.
but nothing else with it, i need to study the code so the easyess way to do it would be the best in this case, thanks in advance~


CS_TBL(Posted 2003) [#2]
blitzplus example (using a canvas)

app=CreateWindow("image scroll example",32,32,384,384)

canvas=CreateCanvas(0,0,320,320,app)




; prepare some image ..

image=CreateImage(800,800)

SetBuffer ImageBuffer(image)

For t=0 To 100
	r=Rnd(0,255)
	g=Rnd(0,255)
	b=Rnd(0,255)
	Color r,g,b
	
	Rect Rnd(0,800),Rnd(0,800),64,64,True
	Color b,r,g
	Oval Rnd(0,800),Rnd(0,800),64,64,True
Next





quit=False

SetBuffer CanvasBuffer(canvas)

Repeat
	WaitEvent()
	If EventID()=$803 quit=True; alt f4 = quit

	If KeyDown(200) ; up
		y=y-4
	EndIf	
	If KeyDown(208) ; down
		y=y+4
	EndIf	
	If KeyDown(203) ; left
		x=x-4
	EndIf	
	If KeyDown(205) ; right
		x=x+4
	EndIf	
	
	DrawImage image,x,y
	
	FlipCanvas canvas:Cls
	
Until quit

FreeImage image
FreeGadget app

End