Games or fun little projects

Games or fun little projects

Postby kevinrandell » Sun Sep 18, 2011 4:35 am

Does any one have any sample projects that they are willing to share? I am currently running a class and I am writing projects as I go with a general game theme.
kevinrandell
 
Posts: 13
Joined: Fri Jun 17, 2011 4:55 am

Re: Games or fun little projects

Postby Slowdown » Sun Sep 18, 2011 9:07 am

Nothing you can use from the examples ?
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: Games or fun little projects

Postby kevinrandell » Wed Sep 21, 2011 6:16 am

The space game looks exactly what I am looking for. However I get a runtime error when running the program
Screen shot 2011-09-21 at 12.10.20 PM.png
Screen shot 2011-09-21 at 12.10.20 PM.png (23.38 KiB) Viewed 1465 times
Screen shot 2011-09-21 at 12.10.20 PM.png
Screen shot 2011-09-21 at 12.10.20 PM.png (23.38 KiB) Viewed 1465 times
Attachments
Screen shot 2011-09-21 at 12.10.35 PM.png
Screen shot 2011-09-21 at 12.10.35 PM.png (18.45 KiB) Viewed 1451 times
kevinrandell
 
Posts: 13
Joined: Fri Jun 17, 2011 4:55 am

Re: Games or fun little projects

Postby berndnoetscher » Wed Sep 21, 2011 2:27 pm

This is a fixed version, problems happend due to variant data type:

Code: Select all
option oldbasic
option explicit off

Dim x as integer
Dim y as integer
Dim Schuss as integer
Dim SchussX as integer
Dim SchussY as integer
Dim Cnt as integer
Dim Cnt2 as integer
Dim ETorpX as integer
Dim ETorpY as integer
Dim ETorp_Running as boolean

/*
Sub Play_Explosion()
    sound1.FileName = "explode.wav"
    sound1.Command = "close"
    sound1.Command = "Open"
    sound1.Command = "Play"
End Sub
*/

' Private Sub Form_OnOpen/*Form_Load*/()
' ' Me.ShowFullScreen
' Energy.value=100
' 'Form33 = Me
' randomize timer
' text1.text=""
' End Sub


Private Sub Form_OnKeyDown(KeyCode As Integer, Shift As Boolean, Control As Boolean, Alt As Boolean)

If KeyCode = Key.Escape Then
    Application.CloseAll
    Application.Stop
End If

If KeyCode = Key.Right Then
    x = x + 15
End If

If KeyCode = Key.Left Then
    x = x - 15
End If
if x < 0 then
  x=0
endif
if x > (500-64) then
  x = 500-64
endif

If KeyCode = Key.Space And Schuss = 0 Then
    Schuss = 1
    SchussX = Ship.X + (Ship.Width / 2) - (Torpedo.Width / 2)
    SchussY = Ship.Y - Torpedo.Height
    Torpedo.X = SchussX
    Torpedo.Y = SchussY
    Torpedo.Visible = True
End If

Ship.X = x
'Text1.Text = ""

End Sub

Private Sub Timer1_OnEvent/*_Timer*/()
  /* the Bonus-Object */

w1=abs(bonus.x - ship.x)
w2=abs(bonus.y - ship.y)
if w1 < 64 and w2 < 64 then
  e=energy.value+rnd(100)
  if e < 100 then
     e=100
  endif
  energy.value=e
 
  bonus.x =  rnd*1200-100
  bonus.y = -1 * rnd*1500+50
 
endif
bonus.y = bonus.y+15
if bonus.y > (Energy.y-50) then
  bonus.x =  rnd*1200+100
  bonus.y = -1 * rnd*1500+50
endif

If Cnt <> 0 Then
    Cnt = Cnt + 1
    If Cnt > 10 Then
        Cnt = 0
        Explosion.Visible = False
        Enemy.Visible = True
    End If
End If

If Cnt2 <> 0 Then
    Cnt2 = Cnt2 + 1
    If Cnt2 > 10 Then
        Cnt2 = 0
        Explosion.Visible = False
        Ship.Visible = True
    End If
End If

If Schuss <> 0 Then
    SchussY = SchussY - (Torpedo.Height / 2)
    Torpedo.Y = SchussY
    Torpedo.X = SchussX
    w1= abs(Torpedo.X - Enemy.X)
    w2 = abs(Torpedo.y - Enemy.y)
    If  w1 < 20 And w2 < 20 then
        Enemy.Visible = False
        Explosion.Y = Enemy.Y
        Explosion.X = Enemy.X
        Explosion.Visible = True
        Schuss = 0
        Torpedo.Visible = False
        Cnt = 1
        Hits.Caption = "" & (val(hits.caption) + 1)
      '  Call Play_Explosion
    End If
End If

If SchussY < -Torpedo.Height Then
    Schuss = 0
    Torpedo.Visible = False
End If

If ETorp_Running = True Then
    ETorpY = ETorpY + (ETorp.Height / 2)+val(Hits.Caption)*5
    ETorp.X = ETorpX
    ETorp.Y = ETorpY
    ETorp.Visible = True
    If ETorpY > Form1.Height Then
        ETorp.Visible = False
        ETorp_Running = False
    End If
    If ETorpX + ETorp.Width >= Ship.X And ETorpX <= (Ship.X + Ship.Width) And ETorpY >= Ship.Y And ETorpY <= (Ship.Y + Ship.Height) Then
        Cnt2 = 1
        Ship.Visible = False
        Explosion.Y = Ship.Y
        Explosion.X = Ship.X
        Explosion.Visible = True
        ETorp_Running = False
        ETorp.Visible = False
        Energy.Value=Energy.value-5
        if energy.value < 1 then
          Application.CloseAll
          Application.Stop
        endif
    End If
End If

If Abs(Enemy.X - Ship.X) < 20 And ETorp_Running = False And Cnt2 = 0 Then
    ETorp_Running = True
    ETorpY = Enemy.Y + Enemy.Height
    ETorpX = Enemy.X + (Enemy.Width / 2) - (ETorp.Width / 2)
End If

If Enemy.X < Ship.X Then
    If Abs(Enemy.X - Ship.X) > 10 Then
        Enemy.X = Enemy.X + 10
    Else
        Enemy.X = Enemy.X + Abs(Enemy.X - Ship.X)
    End If
End If

If Enemy.X > Ship.X Then
    If Abs(Enemy.X - Ship.X) > 10 Then
        Enemy.X = Enemy.X - 10
    Else
        Enemy.X = Enemy.X - Abs(Enemy.X - Ship.X)
    End If
End If

End Sub







berndnoetscher
Site Admin
 
Posts: 1059
Joined: Tue Sep 25, 2007 9:37 am

Re: Games or fun little projects

Postby Slowdown » Wed Sep 21, 2011 2:43 pm

@B
Hmmm i was just a little to late.
Corrected here the example.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: Games or fun little projects

Postby kevinrandell » Sun Sep 25, 2011 7:28 am

Thank you,

Got the code to work OK. There were some logical errors with the energy levels and I declared the variables so that it does not need the oldbasic options.

I made a simple game with 4 way movement that I would like to share.

Regards,
Kevin
Attachments
Space Attack.kbasic_project.zip
(170.79 KiB) Downloaded 233 times
kevinrandell
 
Posts: 13
Joined: Fri Jun 17, 2011 4:55 am

Re: Games or fun little projects

Postby Slowdown » Sun Sep 25, 2011 9:25 am

Nicely done Kevin.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands


Return to Anything Else

cron