Snake Game - within worksheet - cells as pixels
$begingroup$
Since my rather mediocre attempt at making a space invader game I stumbled on a cache of Visual Basic for Applications games written by Japanese excel wizards. I have even had someone create Zelda? What an inspiration! Making complete, beautiful, fun arcade / GameBoy style games inside of an Excel spreadsheet is possible.
This is my first crack at recreating the old game Snake.
Classes:
Snake Part:
Option Explicit
Private Type Properties
row As Long
column As Long
End Type
Private this As Properties
Public Property Let row(ByVal value As Long)
this.row = value
End Property
Public Property Get row() As Long
row = this.row
End Property
Public Property Let column(ByVal value As Long)
this.column = value
End Property
Public Property Get column() As Long
column = this.column
End Property
Public Sub PropertiesSet(ByVal row As Long, ByVal column As Long)
this.row = row
this.column = column
End Sub
TimerWin64:
Option Explicit
Private Declare PtrSafe Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LongInteger) As Long
Private Declare PtrSafe Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LongInteger) As Long
Private Type LongInteger
First32Bits As Long
Second32Bits As Long
End Type
Private Type TimerAttributes
CounterInitial As Double
CounterNow As Double
PerformanceFrequency As Double
End Type
Private Const MaxValue_32Bits = 4294967296#
Private this As TimerAttributes
Private Sub Class_Initialize()
PerformanceFrequencyLet
End Sub
Private Sub PerformanceFrequencyLet()
Dim TempFrequency As LongInteger
QueryPerformanceFrequency TempFrequency
this.PerformanceFrequency = ParseLongInteger(TempFrequency)
End Sub
Public Sub TimerSet()
Dim TempCounterIntital As LongInteger
QueryPerformanceCounter TempCounterIntital
this.CounterInitial = ParseLongInteger(TempCounterIntital)
End Sub
Public Function CheckQuarterSecondPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 0.25 Then
CheckQuarterSecondPassed = True
Else
CheckQuarterSecondPassed = False
End If
End Function
Public Function CheckFiveSecondsPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 10 Then
CheckFiveSecondsPassed = True
Else
CheckFiveSecondsPassed = False
End If
End Function
Public Sub PrintTimeElapsed()
CounterNowLet
If CounterInitalIsSet = True Then
Dim TimeElapsed As Double
TimeElapsed = (this.CounterNow - this.CounterInitial) / this.PerformanceFrequency
Debug.Print Format(TimeElapsed, "0.000000"); " seconds elapsed "
Dim TicksElapsed As Double
TicksElapsed = (this.CounterNow - this.CounterInitial)
Debug.Print Format(TicksElapsed, "#,##0"); " ticks"
End If
End Sub
Private Function CounterNowLet()
Dim TempTimeNow As LongInteger
QueryPerformanceCounter TempTimeNow
this.CounterNow = ParseLongInteger(TempTimeNow)
End Function
Private Function CounterInitalIsSet() As Boolean
If this.CounterInitial = 0 Then
MsgBox "Counter Initial Not Set"
CounterInitalIsSet = False
Else
CounterInitalIsSet = True
End If
End Function
Private Function ParseLongInteger(ByRef LongInteger As LongInteger) As Double
Dim First32Bits As Double
First32Bits = LongInteger.First32Bits
Dim Second32Bits As Double
Second32Bits = LongInteger.Second32Bits
If First32Bits < 0 Then First32Bits = First32Bits + MaxValue_32Bits
If Second32Bits < 0 Then Second32Bits = First32Bits + MaxValue_32Bits
ParseLongInteger = First32Bits + (MaxValue_32Bits * Second32Bits)
End Function
Worksheet Code:
Option Explicit
Public Enum Direction
North = 1
South = 2
East = 3
West = 4
End Enum
Public ws As Worksheet
Public snakeParts As Collection
Public currentRow As Long
Public currentColumn As Long
Public directionSnake As Direction
Sub RunGame()
Set ws = ActiveWorkbook.Sheets("Game")
Set snakeParts = New Collection
Dim gameOver As Boolean
gameOver = False
Dim TimerGame As TimerWin64
Set TimerGame = New TimerWin64
Dim TimerBlueSquare As TimerWin64
Set TimerBlueSquare = New TimerWin64
Dim TimerYellowSquare As TimerWin64
Set TimerYellowSquare = New TimerWin64
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
GameBoardReset
DirectionSnakeInitialize
StartPositionInitalize
StartGameBoardInitalize
TimerGame.TimerSet
TimerBlueSquare.TimerSet
TimerYellowSquare.TimerSet
ws.cells(currentRow, currentColumn).Select
Do While gameOver = False
If TimerGame.CheckQuarterSecondPassed = True Then
CurrentCellUpdate
ws.cells(currentRow, currentColumn).Select
If SnakePartOverlapItself(currentRow, currentColumn) = True Then
gameOver = True
Exit Do
ElseIf SnakePartYellowSquareOverlap = True Then
gameOver = True
Exit Do
ElseIf SnakePartBlueSquareOverlap = True Then
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
Else
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
End If
End If
If TimerBlueSquare.CheckFiveSecondsPassed = True Then
BlueSquareAdd
TimerBlueSquare.TimerSet
End If
If TimerYellowSquare.CheckFiveSecondsPassed = True Then
YellowSquareAdd
TimerYellowSquare.TimerSet
End If
gameOver = OutOfBounds
DoEvents
Loop
End Sub
Private Sub GameBoardReset()
ws.cells.Interior.Color = RGB(300, 300, 300)
End Sub
Private Sub DirectionSnakeInitialize()
directionSnake = East
End Sub
Private Sub StartPositionInitalize()
currentRow = 96
currentColumn = 64
End Sub
Private Sub StartGameBoardInitalize()
Call SnakePartAdd(currentRow, currentColumn - 6)
Call SnakePartAdd(currentRow, currentColumn - 5)
Call SnakePartAdd(currentRow, currentColumn - 4)
Call SnakePartAdd(currentRow, currentColumn - 3)
Call SnakePartAdd(currentRow, currentColumn - 2)
Call SnakePartAdd(currentRow, currentColumn - 1)
Call SnakePartAdd(currentRow, currentColumn)
End Sub
Private Sub SnakePartAdd(ByVal row As Long, ByVal column As Long)
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
SnakePartNew.PropertiesSet row, column
SnakePartAddToCollection SnakePartNew
SnakePartAddToGameBoard SnakePartNew
End Sub
Private Sub SnakePartAddToCollection(ByRef snakepart As snakepart)
snakeParts.add snakepart
End Sub
Private Sub SnakePartAddToGameBoard(ByRef snakepart As snakepart)
ws.cells(snakepart.row, snakepart.column).Interior.Color = RGB(0, 150, 0)
End Sub
Private Sub SnakePartRemove()
SnakePartRemoveFromGameBoard
SnakePartRemoveFromCollection
End Sub
Private Sub SnakePartRemoveFromCollection()
snakeParts.Remove 1
End Sub
Private Sub SnakePartRemoveFromGameBoard()
ws.cells(snakeParts.Item(1).row, snakeParts.Item(1).column).Interior.Color = RGB(300, 300, 300)
End Sub
Private Function OutOfBounds() As Boolean
If currentRow < 9 Or _
currentRow > 189 Or _
currentColumn < 21 Or _
currentColumn > 108 Then
OutOfBounds = True
MsgBox "GameOver"
Else
OutOfBounds = False
End If
End Function
Private Function SnakePartOverlapItself(ByVal row As Long, ByVal column As Long) As Boolean
If ws.cells(row, column).Interior.Color = RGB(0, 150, 0) Then
MsgBox "GameOver"
SnakePartOverlapItself = True
Else
SnakePartOverlapItself = False
End If
End Function
Private Sub BlueSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
End Sub
Private Function SnakePartBlueSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(0, 0, 150) Then
SnakePartBlueSquareOverlap = True
Else
SnakePartBlueSquareOverlap = False
End If
End Function
Private Sub YellowSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
End Sub
Private Function SnakePartYellowSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(255, 140, 0) Then
MsgBox "GameOver"
SnakePartYellowSquareOverlap = True
Else
SnakePartYellowSquareOverlap = False
End If
End Function
Private Sub CurrentCellUpdate()
Select Case directionSnake
Case Is = Direction.North
currentRow = currentRow - 1
Case Is = Direction.South
currentRow = currentRow + 1
Case Is = Direction.East
currentColumn = currentColumn + 1
Case Is = Direction.West
currentColumn = currentColumn - 1
End Select
End Sub
Private Sub SnakeCollectionUpdate(ByRef snakeParts As Collection)
snakeParts.add currentRow
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'rowSwitch
If directionSnake = East Or directionSnake = West Then
If Target.column = currentColumn Then
If Target.row <> currentRow Then
If Target.row = currentRow - 1 Then
directionSnake = North
ElseIf Target.row = currentRow + 1 Then
directionSnake = South
End If
End If
End If
End If
'columnSwitch
If directionSnake = North Or directionSnake = South Then
If Target.row = currentRow Then
If Target.column <> currentColumn Then
If Target.column = currentColumn + 1 Then
directionSnake = East
ElseIf Target.column = currentColumn - 1 Then
directionSnake = West
End If
End If
End If
End If
End Sub
beginner game vba excel
$endgroup$
add a comment |
$begingroup$
Since my rather mediocre attempt at making a space invader game I stumbled on a cache of Visual Basic for Applications games written by Japanese excel wizards. I have even had someone create Zelda? What an inspiration! Making complete, beautiful, fun arcade / GameBoy style games inside of an Excel spreadsheet is possible.
This is my first crack at recreating the old game Snake.
Classes:
Snake Part:
Option Explicit
Private Type Properties
row As Long
column As Long
End Type
Private this As Properties
Public Property Let row(ByVal value As Long)
this.row = value
End Property
Public Property Get row() As Long
row = this.row
End Property
Public Property Let column(ByVal value As Long)
this.column = value
End Property
Public Property Get column() As Long
column = this.column
End Property
Public Sub PropertiesSet(ByVal row As Long, ByVal column As Long)
this.row = row
this.column = column
End Sub
TimerWin64:
Option Explicit
Private Declare PtrSafe Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LongInteger) As Long
Private Declare PtrSafe Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LongInteger) As Long
Private Type LongInteger
First32Bits As Long
Second32Bits As Long
End Type
Private Type TimerAttributes
CounterInitial As Double
CounterNow As Double
PerformanceFrequency As Double
End Type
Private Const MaxValue_32Bits = 4294967296#
Private this As TimerAttributes
Private Sub Class_Initialize()
PerformanceFrequencyLet
End Sub
Private Sub PerformanceFrequencyLet()
Dim TempFrequency As LongInteger
QueryPerformanceFrequency TempFrequency
this.PerformanceFrequency = ParseLongInteger(TempFrequency)
End Sub
Public Sub TimerSet()
Dim TempCounterIntital As LongInteger
QueryPerformanceCounter TempCounterIntital
this.CounterInitial = ParseLongInteger(TempCounterIntital)
End Sub
Public Function CheckQuarterSecondPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 0.25 Then
CheckQuarterSecondPassed = True
Else
CheckQuarterSecondPassed = False
End If
End Function
Public Function CheckFiveSecondsPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 10 Then
CheckFiveSecondsPassed = True
Else
CheckFiveSecondsPassed = False
End If
End Function
Public Sub PrintTimeElapsed()
CounterNowLet
If CounterInitalIsSet = True Then
Dim TimeElapsed As Double
TimeElapsed = (this.CounterNow - this.CounterInitial) / this.PerformanceFrequency
Debug.Print Format(TimeElapsed, "0.000000"); " seconds elapsed "
Dim TicksElapsed As Double
TicksElapsed = (this.CounterNow - this.CounterInitial)
Debug.Print Format(TicksElapsed, "#,##0"); " ticks"
End If
End Sub
Private Function CounterNowLet()
Dim TempTimeNow As LongInteger
QueryPerformanceCounter TempTimeNow
this.CounterNow = ParseLongInteger(TempTimeNow)
End Function
Private Function CounterInitalIsSet() As Boolean
If this.CounterInitial = 0 Then
MsgBox "Counter Initial Not Set"
CounterInitalIsSet = False
Else
CounterInitalIsSet = True
End If
End Function
Private Function ParseLongInteger(ByRef LongInteger As LongInteger) As Double
Dim First32Bits As Double
First32Bits = LongInteger.First32Bits
Dim Second32Bits As Double
Second32Bits = LongInteger.Second32Bits
If First32Bits < 0 Then First32Bits = First32Bits + MaxValue_32Bits
If Second32Bits < 0 Then Second32Bits = First32Bits + MaxValue_32Bits
ParseLongInteger = First32Bits + (MaxValue_32Bits * Second32Bits)
End Function
Worksheet Code:
Option Explicit
Public Enum Direction
North = 1
South = 2
East = 3
West = 4
End Enum
Public ws As Worksheet
Public snakeParts As Collection
Public currentRow As Long
Public currentColumn As Long
Public directionSnake As Direction
Sub RunGame()
Set ws = ActiveWorkbook.Sheets("Game")
Set snakeParts = New Collection
Dim gameOver As Boolean
gameOver = False
Dim TimerGame As TimerWin64
Set TimerGame = New TimerWin64
Dim TimerBlueSquare As TimerWin64
Set TimerBlueSquare = New TimerWin64
Dim TimerYellowSquare As TimerWin64
Set TimerYellowSquare = New TimerWin64
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
GameBoardReset
DirectionSnakeInitialize
StartPositionInitalize
StartGameBoardInitalize
TimerGame.TimerSet
TimerBlueSquare.TimerSet
TimerYellowSquare.TimerSet
ws.cells(currentRow, currentColumn).Select
Do While gameOver = False
If TimerGame.CheckQuarterSecondPassed = True Then
CurrentCellUpdate
ws.cells(currentRow, currentColumn).Select
If SnakePartOverlapItself(currentRow, currentColumn) = True Then
gameOver = True
Exit Do
ElseIf SnakePartYellowSquareOverlap = True Then
gameOver = True
Exit Do
ElseIf SnakePartBlueSquareOverlap = True Then
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
Else
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
End If
End If
If TimerBlueSquare.CheckFiveSecondsPassed = True Then
BlueSquareAdd
TimerBlueSquare.TimerSet
End If
If TimerYellowSquare.CheckFiveSecondsPassed = True Then
YellowSquareAdd
TimerYellowSquare.TimerSet
End If
gameOver = OutOfBounds
DoEvents
Loop
End Sub
Private Sub GameBoardReset()
ws.cells.Interior.Color = RGB(300, 300, 300)
End Sub
Private Sub DirectionSnakeInitialize()
directionSnake = East
End Sub
Private Sub StartPositionInitalize()
currentRow = 96
currentColumn = 64
End Sub
Private Sub StartGameBoardInitalize()
Call SnakePartAdd(currentRow, currentColumn - 6)
Call SnakePartAdd(currentRow, currentColumn - 5)
Call SnakePartAdd(currentRow, currentColumn - 4)
Call SnakePartAdd(currentRow, currentColumn - 3)
Call SnakePartAdd(currentRow, currentColumn - 2)
Call SnakePartAdd(currentRow, currentColumn - 1)
Call SnakePartAdd(currentRow, currentColumn)
End Sub
Private Sub SnakePartAdd(ByVal row As Long, ByVal column As Long)
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
SnakePartNew.PropertiesSet row, column
SnakePartAddToCollection SnakePartNew
SnakePartAddToGameBoard SnakePartNew
End Sub
Private Sub SnakePartAddToCollection(ByRef snakepart As snakepart)
snakeParts.add snakepart
End Sub
Private Sub SnakePartAddToGameBoard(ByRef snakepart As snakepart)
ws.cells(snakepart.row, snakepart.column).Interior.Color = RGB(0, 150, 0)
End Sub
Private Sub SnakePartRemove()
SnakePartRemoveFromGameBoard
SnakePartRemoveFromCollection
End Sub
Private Sub SnakePartRemoveFromCollection()
snakeParts.Remove 1
End Sub
Private Sub SnakePartRemoveFromGameBoard()
ws.cells(snakeParts.Item(1).row, snakeParts.Item(1).column).Interior.Color = RGB(300, 300, 300)
End Sub
Private Function OutOfBounds() As Boolean
If currentRow < 9 Or _
currentRow > 189 Or _
currentColumn < 21 Or _
currentColumn > 108 Then
OutOfBounds = True
MsgBox "GameOver"
Else
OutOfBounds = False
End If
End Function
Private Function SnakePartOverlapItself(ByVal row As Long, ByVal column As Long) As Boolean
If ws.cells(row, column).Interior.Color = RGB(0, 150, 0) Then
MsgBox "GameOver"
SnakePartOverlapItself = True
Else
SnakePartOverlapItself = False
End If
End Function
Private Sub BlueSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
End Sub
Private Function SnakePartBlueSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(0, 0, 150) Then
SnakePartBlueSquareOverlap = True
Else
SnakePartBlueSquareOverlap = False
End If
End Function
Private Sub YellowSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
End Sub
Private Function SnakePartYellowSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(255, 140, 0) Then
MsgBox "GameOver"
SnakePartYellowSquareOverlap = True
Else
SnakePartYellowSquareOverlap = False
End If
End Function
Private Sub CurrentCellUpdate()
Select Case directionSnake
Case Is = Direction.North
currentRow = currentRow - 1
Case Is = Direction.South
currentRow = currentRow + 1
Case Is = Direction.East
currentColumn = currentColumn + 1
Case Is = Direction.West
currentColumn = currentColumn - 1
End Select
End Sub
Private Sub SnakeCollectionUpdate(ByRef snakeParts As Collection)
snakeParts.add currentRow
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'rowSwitch
If directionSnake = East Or directionSnake = West Then
If Target.column = currentColumn Then
If Target.row <> currentRow Then
If Target.row = currentRow - 1 Then
directionSnake = North
ElseIf Target.row = currentRow + 1 Then
directionSnake = South
End If
End If
End If
End If
'columnSwitch
If directionSnake = North Or directionSnake = South Then
If Target.row = currentRow Then
If Target.column <> currentColumn Then
If Target.column = currentColumn + 1 Then
directionSnake = East
ElseIf Target.column = currentColumn - 1 Then
directionSnake = West
End If
End If
End If
End If
End Sub
beginner game vba excel
$endgroup$
add a comment |
$begingroup$
Since my rather mediocre attempt at making a space invader game I stumbled on a cache of Visual Basic for Applications games written by Japanese excel wizards. I have even had someone create Zelda? What an inspiration! Making complete, beautiful, fun arcade / GameBoy style games inside of an Excel spreadsheet is possible.
This is my first crack at recreating the old game Snake.
Classes:
Snake Part:
Option Explicit
Private Type Properties
row As Long
column As Long
End Type
Private this As Properties
Public Property Let row(ByVal value As Long)
this.row = value
End Property
Public Property Get row() As Long
row = this.row
End Property
Public Property Let column(ByVal value As Long)
this.column = value
End Property
Public Property Get column() As Long
column = this.column
End Property
Public Sub PropertiesSet(ByVal row As Long, ByVal column As Long)
this.row = row
this.column = column
End Sub
TimerWin64:
Option Explicit
Private Declare PtrSafe Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LongInteger) As Long
Private Declare PtrSafe Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LongInteger) As Long
Private Type LongInteger
First32Bits As Long
Second32Bits As Long
End Type
Private Type TimerAttributes
CounterInitial As Double
CounterNow As Double
PerformanceFrequency As Double
End Type
Private Const MaxValue_32Bits = 4294967296#
Private this As TimerAttributes
Private Sub Class_Initialize()
PerformanceFrequencyLet
End Sub
Private Sub PerformanceFrequencyLet()
Dim TempFrequency As LongInteger
QueryPerformanceFrequency TempFrequency
this.PerformanceFrequency = ParseLongInteger(TempFrequency)
End Sub
Public Sub TimerSet()
Dim TempCounterIntital As LongInteger
QueryPerformanceCounter TempCounterIntital
this.CounterInitial = ParseLongInteger(TempCounterIntital)
End Sub
Public Function CheckQuarterSecondPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 0.25 Then
CheckQuarterSecondPassed = True
Else
CheckQuarterSecondPassed = False
End If
End Function
Public Function CheckFiveSecondsPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 10 Then
CheckFiveSecondsPassed = True
Else
CheckFiveSecondsPassed = False
End If
End Function
Public Sub PrintTimeElapsed()
CounterNowLet
If CounterInitalIsSet = True Then
Dim TimeElapsed As Double
TimeElapsed = (this.CounterNow - this.CounterInitial) / this.PerformanceFrequency
Debug.Print Format(TimeElapsed, "0.000000"); " seconds elapsed "
Dim TicksElapsed As Double
TicksElapsed = (this.CounterNow - this.CounterInitial)
Debug.Print Format(TicksElapsed, "#,##0"); " ticks"
End If
End Sub
Private Function CounterNowLet()
Dim TempTimeNow As LongInteger
QueryPerformanceCounter TempTimeNow
this.CounterNow = ParseLongInteger(TempTimeNow)
End Function
Private Function CounterInitalIsSet() As Boolean
If this.CounterInitial = 0 Then
MsgBox "Counter Initial Not Set"
CounterInitalIsSet = False
Else
CounterInitalIsSet = True
End If
End Function
Private Function ParseLongInteger(ByRef LongInteger As LongInteger) As Double
Dim First32Bits As Double
First32Bits = LongInteger.First32Bits
Dim Second32Bits As Double
Second32Bits = LongInteger.Second32Bits
If First32Bits < 0 Then First32Bits = First32Bits + MaxValue_32Bits
If Second32Bits < 0 Then Second32Bits = First32Bits + MaxValue_32Bits
ParseLongInteger = First32Bits + (MaxValue_32Bits * Second32Bits)
End Function
Worksheet Code:
Option Explicit
Public Enum Direction
North = 1
South = 2
East = 3
West = 4
End Enum
Public ws As Worksheet
Public snakeParts As Collection
Public currentRow As Long
Public currentColumn As Long
Public directionSnake As Direction
Sub RunGame()
Set ws = ActiveWorkbook.Sheets("Game")
Set snakeParts = New Collection
Dim gameOver As Boolean
gameOver = False
Dim TimerGame As TimerWin64
Set TimerGame = New TimerWin64
Dim TimerBlueSquare As TimerWin64
Set TimerBlueSquare = New TimerWin64
Dim TimerYellowSquare As TimerWin64
Set TimerYellowSquare = New TimerWin64
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
GameBoardReset
DirectionSnakeInitialize
StartPositionInitalize
StartGameBoardInitalize
TimerGame.TimerSet
TimerBlueSquare.TimerSet
TimerYellowSquare.TimerSet
ws.cells(currentRow, currentColumn).Select
Do While gameOver = False
If TimerGame.CheckQuarterSecondPassed = True Then
CurrentCellUpdate
ws.cells(currentRow, currentColumn).Select
If SnakePartOverlapItself(currentRow, currentColumn) = True Then
gameOver = True
Exit Do
ElseIf SnakePartYellowSquareOverlap = True Then
gameOver = True
Exit Do
ElseIf SnakePartBlueSquareOverlap = True Then
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
Else
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
End If
End If
If TimerBlueSquare.CheckFiveSecondsPassed = True Then
BlueSquareAdd
TimerBlueSquare.TimerSet
End If
If TimerYellowSquare.CheckFiveSecondsPassed = True Then
YellowSquareAdd
TimerYellowSquare.TimerSet
End If
gameOver = OutOfBounds
DoEvents
Loop
End Sub
Private Sub GameBoardReset()
ws.cells.Interior.Color = RGB(300, 300, 300)
End Sub
Private Sub DirectionSnakeInitialize()
directionSnake = East
End Sub
Private Sub StartPositionInitalize()
currentRow = 96
currentColumn = 64
End Sub
Private Sub StartGameBoardInitalize()
Call SnakePartAdd(currentRow, currentColumn - 6)
Call SnakePartAdd(currentRow, currentColumn - 5)
Call SnakePartAdd(currentRow, currentColumn - 4)
Call SnakePartAdd(currentRow, currentColumn - 3)
Call SnakePartAdd(currentRow, currentColumn - 2)
Call SnakePartAdd(currentRow, currentColumn - 1)
Call SnakePartAdd(currentRow, currentColumn)
End Sub
Private Sub SnakePartAdd(ByVal row As Long, ByVal column As Long)
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
SnakePartNew.PropertiesSet row, column
SnakePartAddToCollection SnakePartNew
SnakePartAddToGameBoard SnakePartNew
End Sub
Private Sub SnakePartAddToCollection(ByRef snakepart As snakepart)
snakeParts.add snakepart
End Sub
Private Sub SnakePartAddToGameBoard(ByRef snakepart As snakepart)
ws.cells(snakepart.row, snakepart.column).Interior.Color = RGB(0, 150, 0)
End Sub
Private Sub SnakePartRemove()
SnakePartRemoveFromGameBoard
SnakePartRemoveFromCollection
End Sub
Private Sub SnakePartRemoveFromCollection()
snakeParts.Remove 1
End Sub
Private Sub SnakePartRemoveFromGameBoard()
ws.cells(snakeParts.Item(1).row, snakeParts.Item(1).column).Interior.Color = RGB(300, 300, 300)
End Sub
Private Function OutOfBounds() As Boolean
If currentRow < 9 Or _
currentRow > 189 Or _
currentColumn < 21 Or _
currentColumn > 108 Then
OutOfBounds = True
MsgBox "GameOver"
Else
OutOfBounds = False
End If
End Function
Private Function SnakePartOverlapItself(ByVal row As Long, ByVal column As Long) As Boolean
If ws.cells(row, column).Interior.Color = RGB(0, 150, 0) Then
MsgBox "GameOver"
SnakePartOverlapItself = True
Else
SnakePartOverlapItself = False
End If
End Function
Private Sub BlueSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
End Sub
Private Function SnakePartBlueSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(0, 0, 150) Then
SnakePartBlueSquareOverlap = True
Else
SnakePartBlueSquareOverlap = False
End If
End Function
Private Sub YellowSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
End Sub
Private Function SnakePartYellowSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(255, 140, 0) Then
MsgBox "GameOver"
SnakePartYellowSquareOverlap = True
Else
SnakePartYellowSquareOverlap = False
End If
End Function
Private Sub CurrentCellUpdate()
Select Case directionSnake
Case Is = Direction.North
currentRow = currentRow - 1
Case Is = Direction.South
currentRow = currentRow + 1
Case Is = Direction.East
currentColumn = currentColumn + 1
Case Is = Direction.West
currentColumn = currentColumn - 1
End Select
End Sub
Private Sub SnakeCollectionUpdate(ByRef snakeParts As Collection)
snakeParts.add currentRow
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'rowSwitch
If directionSnake = East Or directionSnake = West Then
If Target.column = currentColumn Then
If Target.row <> currentRow Then
If Target.row = currentRow - 1 Then
directionSnake = North
ElseIf Target.row = currentRow + 1 Then
directionSnake = South
End If
End If
End If
End If
'columnSwitch
If directionSnake = North Or directionSnake = South Then
If Target.row = currentRow Then
If Target.column <> currentColumn Then
If Target.column = currentColumn + 1 Then
directionSnake = East
ElseIf Target.column = currentColumn - 1 Then
directionSnake = West
End If
End If
End If
End If
End Sub
beginner game vba excel
$endgroup$
Since my rather mediocre attempt at making a space invader game I stumbled on a cache of Visual Basic for Applications games written by Japanese excel wizards. I have even had someone create Zelda? What an inspiration! Making complete, beautiful, fun arcade / GameBoy style games inside of an Excel spreadsheet is possible.
This is my first crack at recreating the old game Snake.
Classes:
Snake Part:
Option Explicit
Private Type Properties
row As Long
column As Long
End Type
Private this As Properties
Public Property Let row(ByVal value As Long)
this.row = value
End Property
Public Property Get row() As Long
row = this.row
End Property
Public Property Let column(ByVal value As Long)
this.column = value
End Property
Public Property Get column() As Long
column = this.column
End Property
Public Sub PropertiesSet(ByVal row As Long, ByVal column As Long)
this.row = row
this.column = column
End Sub
TimerWin64:
Option Explicit
Private Declare PtrSafe Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LongInteger) As Long
Private Declare PtrSafe Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LongInteger) As Long
Private Type LongInteger
First32Bits As Long
Second32Bits As Long
End Type
Private Type TimerAttributes
CounterInitial As Double
CounterNow As Double
PerformanceFrequency As Double
End Type
Private Const MaxValue_32Bits = 4294967296#
Private this As TimerAttributes
Private Sub Class_Initialize()
PerformanceFrequencyLet
End Sub
Private Sub PerformanceFrequencyLet()
Dim TempFrequency As LongInteger
QueryPerformanceFrequency TempFrequency
this.PerformanceFrequency = ParseLongInteger(TempFrequency)
End Sub
Public Sub TimerSet()
Dim TempCounterIntital As LongInteger
QueryPerformanceCounter TempCounterIntital
this.CounterInitial = ParseLongInteger(TempCounterIntital)
End Sub
Public Function CheckQuarterSecondPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 0.25 Then
CheckQuarterSecondPassed = True
Else
CheckQuarterSecondPassed = False
End If
End Function
Public Function CheckFiveSecondsPassed() As Boolean
CounterNowLet
If ((this.CounterNow - this.CounterInitial) / this.PerformanceFrequency) >= 10 Then
CheckFiveSecondsPassed = True
Else
CheckFiveSecondsPassed = False
End If
End Function
Public Sub PrintTimeElapsed()
CounterNowLet
If CounterInitalIsSet = True Then
Dim TimeElapsed As Double
TimeElapsed = (this.CounterNow - this.CounterInitial) / this.PerformanceFrequency
Debug.Print Format(TimeElapsed, "0.000000"); " seconds elapsed "
Dim TicksElapsed As Double
TicksElapsed = (this.CounterNow - this.CounterInitial)
Debug.Print Format(TicksElapsed, "#,##0"); " ticks"
End If
End Sub
Private Function CounterNowLet()
Dim TempTimeNow As LongInteger
QueryPerformanceCounter TempTimeNow
this.CounterNow = ParseLongInteger(TempTimeNow)
End Function
Private Function CounterInitalIsSet() As Boolean
If this.CounterInitial = 0 Then
MsgBox "Counter Initial Not Set"
CounterInitalIsSet = False
Else
CounterInitalIsSet = True
End If
End Function
Private Function ParseLongInteger(ByRef LongInteger As LongInteger) As Double
Dim First32Bits As Double
First32Bits = LongInteger.First32Bits
Dim Second32Bits As Double
Second32Bits = LongInteger.Second32Bits
If First32Bits < 0 Then First32Bits = First32Bits + MaxValue_32Bits
If Second32Bits < 0 Then Second32Bits = First32Bits + MaxValue_32Bits
ParseLongInteger = First32Bits + (MaxValue_32Bits * Second32Bits)
End Function
Worksheet Code:
Option Explicit
Public Enum Direction
North = 1
South = 2
East = 3
West = 4
End Enum
Public ws As Worksheet
Public snakeParts As Collection
Public currentRow As Long
Public currentColumn As Long
Public directionSnake As Direction
Sub RunGame()
Set ws = ActiveWorkbook.Sheets("Game")
Set snakeParts = New Collection
Dim gameOver As Boolean
gameOver = False
Dim TimerGame As TimerWin64
Set TimerGame = New TimerWin64
Dim TimerBlueSquare As TimerWin64
Set TimerBlueSquare = New TimerWin64
Dim TimerYellowSquare As TimerWin64
Set TimerYellowSquare = New TimerWin64
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
GameBoardReset
DirectionSnakeInitialize
StartPositionInitalize
StartGameBoardInitalize
TimerGame.TimerSet
TimerBlueSquare.TimerSet
TimerYellowSquare.TimerSet
ws.cells(currentRow, currentColumn).Select
Do While gameOver = False
If TimerGame.CheckQuarterSecondPassed = True Then
CurrentCellUpdate
ws.cells(currentRow, currentColumn).Select
If SnakePartOverlapItself(currentRow, currentColumn) = True Then
gameOver = True
Exit Do
ElseIf SnakePartYellowSquareOverlap = True Then
gameOver = True
Exit Do
ElseIf SnakePartBlueSquareOverlap = True Then
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
Else
Call SnakePartAdd(currentRow, currentColumn)
Call SnakePartRemove
ws.cells(currentRow, currentColumn).Select
TimerGame.TimerSet
End If
End If
If TimerBlueSquare.CheckFiveSecondsPassed = True Then
BlueSquareAdd
TimerBlueSquare.TimerSet
End If
If TimerYellowSquare.CheckFiveSecondsPassed = True Then
YellowSquareAdd
TimerYellowSquare.TimerSet
End If
gameOver = OutOfBounds
DoEvents
Loop
End Sub
Private Sub GameBoardReset()
ws.cells.Interior.Color = RGB(300, 300, 300)
End Sub
Private Sub DirectionSnakeInitialize()
directionSnake = East
End Sub
Private Sub StartPositionInitalize()
currentRow = 96
currentColumn = 64
End Sub
Private Sub StartGameBoardInitalize()
Call SnakePartAdd(currentRow, currentColumn - 6)
Call SnakePartAdd(currentRow, currentColumn - 5)
Call SnakePartAdd(currentRow, currentColumn - 4)
Call SnakePartAdd(currentRow, currentColumn - 3)
Call SnakePartAdd(currentRow, currentColumn - 2)
Call SnakePartAdd(currentRow, currentColumn - 1)
Call SnakePartAdd(currentRow, currentColumn)
End Sub
Private Sub SnakePartAdd(ByVal row As Long, ByVal column As Long)
Dim SnakePartNew As snakepart
Set SnakePartNew = New snakepart
SnakePartNew.PropertiesSet row, column
SnakePartAddToCollection SnakePartNew
SnakePartAddToGameBoard SnakePartNew
End Sub
Private Sub SnakePartAddToCollection(ByRef snakepart As snakepart)
snakeParts.add snakepart
End Sub
Private Sub SnakePartAddToGameBoard(ByRef snakepart As snakepart)
ws.cells(snakepart.row, snakepart.column).Interior.Color = RGB(0, 150, 0)
End Sub
Private Sub SnakePartRemove()
SnakePartRemoveFromGameBoard
SnakePartRemoveFromCollection
End Sub
Private Sub SnakePartRemoveFromCollection()
snakeParts.Remove 1
End Sub
Private Sub SnakePartRemoveFromGameBoard()
ws.cells(snakeParts.Item(1).row, snakeParts.Item(1).column).Interior.Color = RGB(300, 300, 300)
End Sub
Private Function OutOfBounds() As Boolean
If currentRow < 9 Or _
currentRow > 189 Or _
currentColumn < 21 Or _
currentColumn > 108 Then
OutOfBounds = True
MsgBox "GameOver"
Else
OutOfBounds = False
End If
End Function
Private Function SnakePartOverlapItself(ByVal row As Long, ByVal column As Long) As Boolean
If ws.cells(row, column).Interior.Color = RGB(0, 150, 0) Then
MsgBox "GameOver"
SnakePartOverlapItself = True
Else
SnakePartOverlapItself = False
End If
End Function
Private Sub BlueSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(0, 0, 150)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(0, 0, 150)
End Sub
Private Function SnakePartBlueSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(0, 0, 150) Then
SnakePartBlueSquareOverlap = True
Else
SnakePartBlueSquareOverlap = False
End If
End Function
Private Sub YellowSquareAdd()
Dim TopLeftCornerRow As Long
Dim TopLeftCornerColumn As Long
TopLeftCornerRow = Application.WorksheetFunction.RandBetween(9, 189)
TopLeftCornerColumn = Application.WorksheetFunction.RandBetween(21, 108)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn).Interior.Color = RGB(255, 140, 0)
ws.cells(TopLeftCornerRow + 1, TopLeftCornerColumn + 1).Interior.Color = RGB(255, 140, 0)
End Sub
Private Function SnakePartYellowSquareOverlap() As Boolean
If ws.cells(currentRow, currentColumn).Interior.Color = RGB(255, 140, 0) Then
MsgBox "GameOver"
SnakePartYellowSquareOverlap = True
Else
SnakePartYellowSquareOverlap = False
End If
End Function
Private Sub CurrentCellUpdate()
Select Case directionSnake
Case Is = Direction.North
currentRow = currentRow - 1
Case Is = Direction.South
currentRow = currentRow + 1
Case Is = Direction.East
currentColumn = currentColumn + 1
Case Is = Direction.West
currentColumn = currentColumn - 1
End Select
End Sub
Private Sub SnakeCollectionUpdate(ByRef snakeParts As Collection)
snakeParts.add currentRow
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'rowSwitch
If directionSnake = East Or directionSnake = West Then
If Target.column = currentColumn Then
If Target.row <> currentRow Then
If Target.row = currentRow - 1 Then
directionSnake = North
ElseIf Target.row = currentRow + 1 Then
directionSnake = South
End If
End If
End If
End If
'columnSwitch
If directionSnake = North Or directionSnake = South Then
If Target.row = currentRow Then
If Target.column <> currentColumn Then
If Target.column = currentColumn + 1 Then
directionSnake = East
ElseIf Target.column = currentColumn - 1 Then
directionSnake = West
End If
End If
End If
End If
End Sub
beginner game vba excel
beginner game vba excel
edited 12 mins ago
Jamal♦
30.3k11119227
30.3k11119227
asked 32 mins ago
learnAsWeGolearnAsWeGo
2417
2417
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214630%2fsnake-game-within-worksheet-cells-as-pixels%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214630%2fsnake-game-within-worksheet-cells-as-pixels%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown