C# :: Snake Game Using 2D Arrays
Jun 1, 2014
I'm trying to make a simple snake game in C# using 2 Dimensional Arrays . I have a grid of labels. I am having problems with differentiating the head of the snake from the rest of it's body. Also I need generating 2 random numbers and filling them inside my array.
I don't know how to place random food on my array. This is because the food can't be placed on the location of the snake. Which brings me to my other problem which is keeping track of the snake and updating it. I don't know what structure to use and How to actually do the above methods. I've tried looking at a lot of sample snake projects but they don't have arrays in them.
View 14 Replies
Apr 15, 2015
I am trying to make a basic Snake game using the command window and screen refreshes. So far I have a board, snake, food, and no walls. Basically I have it so the snake moves like the traditional snake in the game, when it eats the food once it grows. However when it eats the food a second time the game crashes. I think I have narrowed the issue down to the grow array that I have (below) but I am not sure if the issue could be a result of something else.
Grow Array
cord growArray (cord *p_values, int *size)
{
*size = *size + 1;
cord *p_new_values = new cord[ *size ];
[Code]....
View 7 Replies
View Related
Jan 3, 2014
i want to draw a 3D snake in opengl.. i can't get nothing out of my search to make a start.. how it is made
View 4 Replies
View Related
Sep 25, 2012
Objective : Code a game allowing two human players to play tictactoe.
Create 2 classes:
-Create a 3 x 3, 2-D array board class to play the game.
-Player; has a private string name data member and a method that reads the players’ row and column selections from the keyboard.
Create 2 player objects from this class. Name the players Orestes and Xerxes.
Think carefully about board and player classes responsibilities and how they interaction with one another. The players do not collaborate with one another but they collaborate with the board.
My Problem : The program compiles with the header file, but it the displaying is wrong as you will see when you enter your row and column.
Sources
Header file:
Code:
#include <iostream>
#include <string>
using namespace std;
class Board {
public:
void display(char Z[][3], int row, int col);
[Code] ....
View 1 Replies
View Related
Nov 3, 2013
I have been coding a while on a 2D random terrain game. How would I go about saving the maps? I have an array for blocks, lighting, background and background lighting. The lighting is done in real-time, so exclude that.
But with two 32000x3200 arrays, I still need to store 204800000 separate numbers in a file. Oh god. How can I have this? I could write down the separate numbers, but...yeah.
If it matters, this is made in freeglut.
View 2 Replies
View Related
Mar 6, 2015
I'm supposed to create a "game" that is similar to Candy Crush or Bejeweled. The assignment takes in a .txt file that contains a matrix of values from 1-5 and then assigns each value to a spot in a [10][10] array. Then an Escape Code function prints out colored pixels in place of the number values for each spot, creating a "game board" looking output. Finally, the program is supposed to look for any matches of 3 same-colored pixels and replace them with a white pixel and "XX". Then the program prints the corrected game board with the matches X'd out.
I have it mostly coded, but I've encountered a couple of issues.
1.) I am supposed to label the columns and rows 0-9, and while I have no problem coding the labels for the columns using printf( ), when I try to print the row labels I get a random string of numbers.
2.) I replaced the matches with white pixels by reassigning the value in the array to 7, for which the ANSI Escape Code is white. However, I'm unsure about how to print the "XX" in the same spot.
Here is the input(.txt) file and the output of the program so far:
And here is what I have coded at this point:
Code:
#include <stdio.h>
void printEscapeCode(int c);
int main(void)
{
/* Declare an image array to be gameboard */
int gameboard[10][10];
/* Declare variables and load in how many rows and columns */
int Nrows;
Nrows = 0;
[code]....
View 2 Replies
View Related
Feb 26, 2014
I have a sword(25 damage), spear(20 damage), arrow(15 damage), dagger(10 damage) and knife(5 damage). I want to make a class for them so that I can equip one of them in battle and use them to inflict damage.
View 1 Replies
View Related
Nov 11, 2014
My assignment is writing Madd Libs game. I still do not understand how to store inputted strings or values to arrays. I need explanation of collecting inputted data to arrays.
#include "stdafx.h"
#include<stdio.h>
//#include<string.h>
int main(void) {
char string[37] = {'