Note that there are some explanatory texts on larger screens.

plurals
  1. POConfused on where to go from here: simple snake game Python 3
    primarykey
    data
    text
    <p>I am new to programming and and am currently taking my first class! We use python 3 and for our last project we have been assigned to write a simple game of snake. The stepwise refinement is as follows:</p> <p>creates an board of size 20 rows, 30 columns displays the board places the player and the snake on the board prompts the user to press a key and loops, displaying the board again every time the user presses a new key (this can be an innite loop for now) moves the player around on the board based on the user input - remember to both move the "i" to new coordinates as well as revert the original coordinates adds the function that adds a random point to the end of the snake every ve moves. You should create a counter to count how many moves have passed since the last snake addition. adds the function that moves the snake adds a check if the user's move will touch the snake or if the snake can no longer move. If so, your program should print an appropriate statement</p> <p>right now I have my matrix (board) made and displayed but I am confused where to begin now. </p> <p>The snake begins with a length of 3, meaning that it takes up 3 coordinates on the board. You take up one coordinate on the board. Every 5 moves, the snake grows its tail by 1 coordinate (for example, on the sixth move the snake should be of length 4). So, after the rst ve moves, the snake has a length of 4. </p> <p>The game is supposed to be so basic that the snake moves one place (closer) every time I move the player. </p> <p>Here's my code so far:</p> <p>any help or direction will be greatly appreciated!!!! </p> <pre><code> def main(): board = createBoard(20, 30) displayBoard(board) def createArray(size): return ["_ "] * size def createBoard(rows, cols): matrix = createArray(rows) for i in range(rows): matrix[i] = createArray(cols) return matrix def displayBoard(m): for i in range(len(m)): for j in range(len(m[0])): print(m[i][j], end="") print() #creates a new line main() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload