#85199 - 2002-03-09 10:33 PM
Re: Where is KiXlander - Game by Shawn
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Here's the source code to KiXlander, but remember that you still need the graphics and sound files from the distribution package to play this game:
code:
break on ; ; KiXlander ; ; Requires: ; KIXTART 4.02 ; KIXFORMS BUILD 7 ; ; This is a port of a Public Domain Visual Basic ; Lander program - with mods by yours truely. ; ; Use the enter key to start your decent. Use the up-arrow ; key to apply thrust. When done, use the enter key to reset ; the lander and again, to start your next decent. ; ; -Shawn ; srnd(-1*@ticks) ; Randomize $SOUNDS = 1 ; set to zero to turn sounds off $SCRIPT = "KiXlander" $VERSION = "1.7" $AUTHOR = "-Shawn" $CAPTION = "$SCRIPT v$VERSION" ; ; Resources ; $BACKGND = "@curdir\backgnd.bmp" $CLOUD = "@curdir\cloud.bmp" $LANDER = "@curdir\lander.bmp" $CRASH = "@curdir\crash.bmp" $BOOM = "@curdir\boom2.wav" $LANDED = "@curdir\landed.wav" $soundlib = "boom.wav", "problem.wav", "notgood.wav", "safe.wav", "dstruct1.wav", "kaboom.wav", "fading.wav", "100safe.wav", "lsngwarp.wav", "dontfail.wav", "whatjunk.wav", "averted.wav", "letshope.wav", "wndofail.wav", "drawing.wav", "engrfeat.wav", "idontlik.wav", "short.wav", "boom4.wav", "crash.wav", "crash4.wav", "down.wav" $WHITE = &0FFFFFF $BLACK = &0 $GREEN = &000FF00 $YELLOW = &0AAFFFF ; ; Settings ; $MAXFUEL = 1000 ; ; Setup the form ; $Form = CreateObject("Kixtart.Form") $Form.Picture = $CLOUD $Form.BorderStyle = 1 $Form.MinButton = 1 $Form.MaxButton = 0 $Form.Caption = "$CAPTION" $Form.ScaleWidth = 475 $Form.ScaleHeight = 585 $Form.ForeColor = $WHITE $txtFuel = $Form.Textbox $txtFuel.Left = 352 $txtFuel.Top = 25 $txtFuel.Width = 113 $txtFuel.Height = 25 $txtFuel.Text = "$MAXFUEL" $txtFuel.FontName = "Courier New" $txtFuel.FontSize = 12 $txtFuel.FontWeight = 600 $txtFuel.BackColor = $BLACK $txtFuel.ForeColor = $GREEN $txtSpeed = $Form.Textbox $txtSpeed.Left = 352 $txtSpeed.Top = 75 $txtSpeed.Width = 113 $txtSpeed.Height = 25 $txtSpeed.Text = "0" $txtSpeed.FontName = "Courier New" $txtSpeed.FontSize = 12 $txtSpeed.FontWeight = 600 $txtSpeed.BackColor = $BLACK $txtSpeed.ForeColor = $GREEN $txtHeight = $Form.Textbox $txtHeight.Left = 352 $txtHeight.Top = 125 $txtHeight.Width = 113 $txtHeight.Height = 25 $txtHeight.Text = "500.0" $txtHeight.FontName = "Courier New" $txtHeight.FontSize = 12 $txtHeight.FontWeight = 600 $txtHeight.BackColor = $BLACK $txtHeight.ForeColor = $GREEN $picEarth = $Form.PictureBox $picEarth.Picture = "$BACKGND" $picEarth.Left = 8 $picEarth.Top = 8 $picEarth.Width = 336 $picEarth.Height = 568 $picEarth.BorderStyle = 0 $imgLander = $picEarth.Image $imgLander.Picture = "$LANDER" $imgLander.Left = ($picEarth.ScaleWidth-$imgLander.Width)/2 $cmdStart = $Form.CommandButton $cmdStart.Left = 352 $cmdStart.Top = 160 $cmdStart.Width = 115 $cmdStart.Height = 25 $cmdStart.Caption = "Start" $cmdStart.FontName = "MS Sans Serif" $cmdStart.FontSize = 12 $cmdStart.FontBold = 1 $cmdStart.Default = 1 $cmdStart.OnClick = "cmdStart_Click" $Form.FontSize = 10 $Form.ForeColor = $YELLOW $Form.PrintXY(352,10,"Fuel:") $Form.PrintXY(352,60,"Speed:") $Form.PrintXY(352,110,"Altitude:") $Form.FontSize = 8 $Form.ForeColor = $Form.RGB(255,255,0) $Form.PrintXY(360,490,"Powered by:") $Form.PrintXY(360,505,"KiXtart v@KIX") $Form.PrintXY(360,520,"Kixforms Build 7") $Form.PrintXY(360,535,"Author: Shawn") $Fuel = $MAXFUEL $txtFuel.text = $fuel $MaxX = $picEarth.ScaleWidth $MaxY = $picEarth.ScaleHeight $Speed = 0 $Form.Center $Instructions = " Press the ENTER key to start your decent. Use the UP-ARROW to apply thrust. When done, reset the game with the ENTER key. -Shawn " $Form.MsgBox($Instructions,$CAPTION) $Form.Show while $Form.Visible $=Execute($Form.DoEvents) Loop Exit 1 Function cmdStart_Click() $cmdStart.Enabled = 0 $cmdStart.Default = 0 $Timer = 0 ; Start an Asynchronous event loop ; This is done with DoEvents(1) [nowait] While $Form.Visible $=Execute($Form.DoEvents(1)) If @Ticks > $Timer ; Gravity timer returns 1 if ; we've crashed - reset the game If Gravity_Timer() = 1 $cmdStart.Caption = "Reset" $cmdStart.OnClick = "cmdReset_click" $cmdStart.Default = 1 $cmdStart.Enabled = 1 Return EndIf ; Ensure we wait at least 1 msec ; before the next timer fires. $Timer = @TICKS + 1 Endif Loop EndFunction Function Gravity_Timer() ; Not using timediff at this time ; But the timediff can be factored ; into the equation if desired, eg: ; $Speed = $Speed + $TimeDiff / 10 If $TimeNow = 0 ; first time ? $TimeNow = @TICKS $CurTime = $TimeNow Else $TimeNow = @TICKS $TimeDiff = $TimeNow - $CurTime $Speed = $Speed + 1 ; Check if up-arrow pressed and if we have enough ; fuel to thrust ... If $Form.KeyState(&26) and $Fuel > 0 $Speed = $Speed - 2 $Fuel = $Fuel - 5 $txtFuel.Text = $Fuel $Thrust = 0 EndIf $Delta = $Speed / 6 ; Check if we're near the ground ... If $imgLander.Top + $Delta > 490 $imgLander.Top = 490 $txtHeight.Text = 0 $txtSpeed.Text = $Speed ; Have we crashed ... If $Speed > 9 $imgLander.Picture = "$CRASH" If $Sounds $Fun=$fun+1 If $Fun = 4 or RND(4) = 2 $Sound = $SoundLib[RND(UBound($SoundLib))] Play "$Sound" $Fun=0 Else Play "$BOOM" Endif EndIf Else ; We've landed ok ... If $sounds Play "$LANDED" EndIf EndIf $Gravity_Timer = 1 ; Flag to reset Return Endif ; Move the ship $imgLander.Top = $imgLander.Top + $Delta $txtHeight.text = 500 - $imgLander.Top $txtSpeed.Text = $Speed $curTime = $TimeNow EndIf EndFunction Function cmdReset_Click() ; Reset the game $TimeNow = 0 $Timer = 0 $Speed = 0 $txtSpeed.Text = 0 $Fuel = $MAXFUEL $txtFuel.Text = $Fuel $imgLander.Top = 0 $txtHeight.Text = 500 $imgLander.Picture = "$LANDER" $cmdStart.OnClick = "cmdStart_click" $cmdStart.Caption = "Start" EndFunction
-Shawn [ 09 March 2002, 22:48: Message edited by: Shawn ]
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|