by oodan on Sat Sep 10, 2011 4:21 pm
Hi acain here is the code
Module GameLogic
Public Sub Main()
'Opens a new Graphics Window
Core.OpenGraphicsWindow("Game", 800, 600)
'Open Audio Device
Audio.OpenAudio()
'Load Resources
LoadResources()
Dim bug As Sprite
bug = Graphics.CreateSprite(GameImage("sprite"))
bug.Movement.X = 0.5
bug.Movement.Y = 0.5
'Make the mouse cursor dissapear
Input.ShowMouse(False)
'Game Loop
Do
'Clears the Screen to Black
SwinGame.Graphics.ClearScreen()
'Replace mouse with a target
Input.GetMousePosition()
Graphics.DrawBitmapOnScreen(GameImage("target"), mousePoint.X, mousePoint.Y)
'Move the bug and bounce it off the wall
Graphics.DrawSprite(bug)
Graphics.UpdateSprite(bug)
If bug.X + bug.Width + bug.Y + bug.Height >= Core.ScreenWidth + Core.ScreenHeight Then
bug.Movement.X = -0.5
bug.Movement.Y = -0.5
Audio.PlaySoundEffect(GameSound("hit20"), 5, 1)
End If
If bug.X + bug.Width + bug.Y + bug.Height <= 0 Then
bug.Movement.X = 0.5
bug.Movement.Y = 0.5
Audio.PlaySoundEffect(GameSound("hit20"), 5, 1)
End If
If Input.IsKeyPressed(Keys.VK_UP) = True Then
Audio.SetMusicVolume(Audio.MusicVolume + 0.01F)
End If
If Input.IsKeyPressed(Keys.VK_DOWN) = True Then
Audio.SetMusicVolume(Audio.MusicVolume - 0.01F)
End If
'Refreshes the Screen and Processes Input Events
Core.RefreshScreen()
Core.ProcessEvents()
Loop Until SwinGame.Core.WindowCloseRequested() = True
'Free Resources and Close Audio, to end the program.
FreeResources()
Graphics.FreeSprite(bug)
Audio.CloseAudio()
Music.Stop()
End Sub
End Module