This game is simple, but maybe someone else can enhance it. ;-)
In this multi player version of snake, the two snakes are controlled by the joystick. (I only have one good joystick, so I configured the two analog pads to each control a snake; you will probably need to reconfigure the controls, anyway.
)
The snakes can go over their own trails, but not the trails of the other players.
This game can easily be expanded to support 3 or 4 players if you have the hardware. ;-)
' Snake! v1.0
' (C) 2008 Innova and Kristopher Windsor
Const screenx = 800, screeny = 600, player_max = 2
Type player_type
As Single x, y
As Double angle
As Single Ptr jx, jy
As Uinteger c, score
End Type
Dim Shared As Single x1, x2, x3, x4
Dim Shared As player_type player(1 To player_max)
Screenres screenx, screeny, 32
Randomize Timer
Sub setup
For i As Integer = 1 To player_max
With player(i)
.x = (i - .5) * screenx / player_max
.y = screeny / 2
.angle = Atn(1) * 2
If .c = 0 Then
'game has not started
.c = Rgb(Rnd * 256, Rnd * 256, Rnd * 256)
Select Case i
Case 1
.jx = @x1
.jy = @x2
Case 2
.jx = @x4
.jy = @x3
End Select
End If
End With
Next i
End Sub
setup
Do
Getjoystick(0,, x1, x2, x3, x4)
For i As Integer = 1 To player_max
With player(i)
If Abs(*.jy) + Abs(*.jx) > .08 Then .angle = Atan2(*.jy, *.jx)
.x += Cos(.angle)
.y += Sin(.angle)
If .x < 0 Then .x += screenx
If .x > screenx - 1 Then .x -= screenx
If .y < 0 Then .y += screeny
If .y > screeny - 1 Then .y -= screeny
For i2 As Integer = 1 To player_max
If i <> i2 Then
If Point(.x, .y) = player(i2).c Then
Circle (.x, .y), 8, &HFFFFFFFF
player(i2).score += 1
Print "Player " & i2 & " now has " & player(i2).score & " points"
setup
Sleep
Cls
End If
End If
Next i2
End With
Next i
For i As Integer = 1 To player_max
With player(i)
Pset (.x, .y), .c
End With
Next i
Sleep 10
Loop Until Inkey = Chr(27)
Print "Final Score:"
For i As Integer = 1 To player_max
With player(i)
Print "Player " & i & ": " & .score
End With
Next i
Sleep