New to Programming

BlitzMax Forums/BlitzMax Beginners Area/New to Programming

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

heres another example i whipped up...

'Set the complier to strict mode
Strict

'Change the title of the graphics window
AppTitle="Rotation Example"

'Set the mask color to white
SetMaskColor 255,255,255

'Load the BlitzMax logo from the doc folder in the BlitzMax path and masked
'all the white pixels in the file so they will not show up when the pic. is drawn
Local bmax_logo:TImage=LoadImage("..\doc\bmax120.png",MASKEDIMAGE)

'Set the logo's handle to the middle
MidHandleImage bmax_logo

'Declare the rotation value varible
Local rotation:Float=0

'Declare the logo's x coordinate varible
Local bmax_logo_x:Int=400

'Declare the logo's y coordinate varible
Local bmax_logo_y:Int=300

'Create the graphics window
Graphics 800,600,0

'Begin the main loop and wait for the user to press the ESC key
Repeat

'clear the screen
Cls

	'Check to see if the left arrow key has been pressed
	If KeyDown(KEY_LEFT)
		'If the left key was pressed then subtract one from the logo's x
		'moving the logo to the left one pixel
		bmax_logo_x:-1
	EndIf
	
	'Check to see if the right arrow key has been pressed
	If KeyDown(KEY_RIGHT)
		'If the right key was pressed then subtract one from the logo's x
		'moving the logo to the right one pixel
		bmax_logo_x:+1
	EndIf
	
	'Check to see if the up arrow key has been pressed
	If KeyDown(KEY_UP)
		'If the up key was pressed then subtract one from the logo's x
		'moving the logo up one pixel
		bmax_logo_y:-1
	EndIf
	
	'Check to see if the down arrow key has been pressed
	If KeyDown(KEY_DOWN)
		'If the down key was pressed then subtract one from the logo's x
		'moving the logo down one pixel
		bmax_logo_y:+1
	EndIf
	
	'Add one to the rotation number, turning the logo one degrees
	rotation:+1
	
	'Check to see if the rotation number has become greater than 360
	If rotation>360
		'If the rotation number has become greater than 360
		'make the rotation value equal 0 degrees
		rotation=0
	EndIf
	
	'Set the rotation of the logo to the value of rotation
	SetRotation rotation
	
	'Draw the logo at its x and y coordinates
	DrawImage bmax_logo,bmax_logo_x,bmax_logo_y
	
'Show the logo
Flip

Until KeyDown(KEY_ESCAPE)
'End of main loop

Hopefully that will help you to and welcome to the community! :-)
If you have any questions feel free to ask.