Post by tschwarz on Jul 12, 2007 0:42:43 GMT -5
I'm just starting out with Brutus so, I thought I would ask and make sure I'm starting on the right foot.
option explicit
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Declare your variables
dim bRunning
dim ImgShip
Dim ScrnX
Dim ScrnY
Dim MoveShipX
Dim MoveShipY
bRunning = True
MoveShipX = 0
ScrnX = 1024
ScrnY = 768
Call InitializeSettings
Call Main()
'****************************************************************************************
sub main()
do while bRunning = True
if key.pressed(vk_escape) or key.pressed(vk_windowx) = True then bRunning = False
graphics.clear
'start position
graphics.SetX ImgShip, ScrnX / 4
graphics.Sety ImgShip, ScrnY / 2
graphics.SetImage(ImgShip)
Call MoveShip
graphics.display
loop
Key.terminate
Graphics.terminate
Mouse.terminate
end sub
Sub MoveShip
if key.pressed (vk_LEFT) and graphics.GetX(ImgShip) > (graphics.GetWidth(ImgShip)/2) then ' left
moveShipX = moveShipX - 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetX(ImgShip)
elseif key.pressed(vk_RIGHT) and graphics.GetX(ImgShip) < ScrnX - graphics.GetWidth(ImgShip) then ' right
moveShipX = moveShipX + 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetX(ImgShip)
elseif key.pressed(vk_UP) and graphics.GetY(ImgShip) > graphics.GetHeight(ImgShip) then ' up
moveShipY = moveShipY - 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetY(ImgShip)
elseif key.pressed(vk_DOWN) and graphics.GetY(ImgShip) < ScrnY - (graphics.GetHeight(ImgShip)*2) then ' down
moveShipY = moveShipY + 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetY(ImgShip)
end if
End sub
Sub InitializeSettings
if (graphics.initialize(ScrnX,ScrnY,false) <> True) then exit sub 'Run full screen
Key.initialize 'Initialize Keyboard
Mouse.initialize 'Initialize Mouse
Mouse.hide
'Load Images
ImgShip = graphics.loadimage("shiptest.png") ' load the image
End sub
option explicit
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Declare your variables
dim bRunning
dim ImgShip
Dim ScrnX
Dim ScrnY
Dim MoveShipX
Dim MoveShipY
bRunning = True
MoveShipX = 0
ScrnX = 1024
ScrnY = 768
Call InitializeSettings
Call Main()
'****************************************************************************************
sub main()
do while bRunning = True
if key.pressed(vk_escape) or key.pressed(vk_windowx) = True then bRunning = False
graphics.clear
'start position
graphics.SetX ImgShip, ScrnX / 4
graphics.Sety ImgShip, ScrnY / 2
graphics.SetImage(ImgShip)
Call MoveShip
graphics.display
loop
Key.terminate
Graphics.terminate
Mouse.terminate
end sub
Sub MoveShip
if key.pressed (vk_LEFT) and graphics.GetX(ImgShip) > (graphics.GetWidth(ImgShip)/2) then ' left
moveShipX = moveShipX - 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetX(ImgShip)
elseif key.pressed(vk_RIGHT) and graphics.GetX(ImgShip) < ScrnX - graphics.GetWidth(ImgShip) then ' right
moveShipX = moveShipX + 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetX(ImgShip)
elseif key.pressed(vk_UP) and graphics.GetY(ImgShip) > graphics.GetHeight(ImgShip) then ' up
moveShipY = moveShipY - 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetY(ImgShip)
elseif key.pressed(vk_DOWN) and graphics.GetY(ImgShip) < ScrnY - (graphics.GetHeight(ImgShip)*2) then ' down
moveShipY = moveShipY + 5
graphics.SetAutoMove ImgShip, moveShipX, moveShipY, 10
graphics.GetY(ImgShip)
end if
End sub
Sub InitializeSettings
if (graphics.initialize(ScrnX,ScrnY,false) <> True) then exit sub 'Run full screen
Key.initialize 'Initialize Keyboard
Mouse.initialize 'Initialize Mouse
Mouse.hide
'Load Images
ImgShip = graphics.loadimage("shiptest.png") ' load the image
End sub