Montag, 25. Februar 2013

W2

http://pastebin.com/JEM7Ctq5

Wartet

Nur kurz eine Erinnerung an mich wenn ich Zuhause bin. Mein Code liegt bei, ist Open Source unter Namensnennung (Flacx)

Pastebin: http://pastebin.com/mwsDf6a7

Code:

;start
.startpoint
Graphics 1280, 1024, 0, 1
SetBuffer BackBuffer()
SeedRnd MilliSecs()
HidePointer

Global PlayerHealth = 100, PlayerEnergy = 100, PlayerSpeed = 5
Global PlayerPosX = 100, PlayerPosY = 100

Global EnemyHealth = 20, EnemyPosX, EnemyPosY

Global DoesAttackBool = 0

EnemyPosX = Rand(0, 1240)
EnemyPosY = Rand(0, 984)

EnemyChar = LoadImage("clyde-pacman.jpg")
Global EnemyDamage

MouseUsed = 0


.mainscreen
While Not KeyHit(28)

Cls

Color 0,0,0
Rect 0, 0, 600, 400

Color 250, 250, 250
Text 50, 30, "Press 1 for Arrow Keys (Default) and Press 2 for Mouse mode (Go trough Wall disabled)"
Text 50, 50, "Press ENTER to continue..."
Text 50, 70, "Press Press F9 to go back to this Menu"

If KeyHit(2) Then MouseUsed = 0
If KeyHit(3) Then MouseUsed = 1

Flip

Wend

While Not KeyHit(1)
Cls

DoesAttackBool = Rand(0, 1) ; 0 No 1 Yes
If DoesAttack = 1 Then
EnemyDamage = Rand(1, 15)
PlayerHealth = PlayerHealth - EnemyDamage
EndIf

If MouseUsed = 1 Then
PlayerPosX = MouseX()
PlayerPosY = MouseY()
EndIf

Color 0, 0, 250
Text 50, 50, "Player Health: " + PlayerHealth
Text 50, 70, "Enemy Health: " + EnemyHealth

Color 0,0,0
Rect 0, 0, 1024, 600

Color 0, 0, 0
Rect PlayerPosX, PlayerPosY, 20, 20
Color 250, 250, 250
Text PlayerPosX, PlayerPosY, "@"

Color 0, 0, 250
DrawImage EnemyChar, EnemyPosX, EnemyPosY

If KeyDown(200) Then PlayerPosY = PlayerPosY - PlayerSpeed
If KeyDown(203) Then PlayerPosX = PlayerPosX - PlayerSpeed
If KeyDown(205) Then PlayerPosX = PlayerPosX + PlayerSpeed
If KeyDown(208) Then PlayerPosY = PlayerPosY + PlayerSpeed

If KeyHit(68) Then Goto mainscreen

If PlayerPosX < 0 Then PlayerPosX = 1280
If PlayerPosX > 1280 Then PlayerPosX = 1
If PlayerPosY < 0 Then PlayerPosY = 1024
If PlayerPosY > 1024 Then PlayerPosY = 1

If EnemyHealth < 0 Then Goto win
If PlayerHealth < 0 Then Goto loose

Flip

Wend


.win
While Not KeyHit(28)

Cls
Color 250, 250, 250
Text 50, 50, "You won!"
Text 50, 70, "Press ENTER to end Game..."

Flip

Wend
Goto End



.loose
While Not KeyHit(28)

Color 250, 250, 250
Text 50, 50, "You Lost!"
Text 50, 70, "Press ENTER to end Game..."

Flip

Wend


.End
End