C :: Creating Match-3 (Candy Crush) Game Using Arrays

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


ADVERTISEMENT

C :: How To Edit Printed Array Board For Simple Candy Crush Game

Oct 24, 2013

I am required to create a simple candy crush game.

I am this stage where I am required to print the 'box' for navigation purpose at the center of the board once the program initializes.

Here is the code:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//FUNCTION: Draw the Board

[Code].....

I understand that the sequence could be to clear the screen and print the whole board with the indicated marker.

*Yes I am required to move the box in later part of the program but for now, I just need to get the box to show up at coordinate

Code: board[5][5]

I am stuck ...

View 11 Replies View Related

C :: Generate Set Of Random Numbers On Board (2D Array) Like Candy Crush

Oct 15, 2013

Assignment on making a program like candy crush but it is called as number crush.

View 3 Replies View Related

C++ :: Match Word To Definition Hangman Game

Jun 25, 2014

Basically I have a text file called words. I'm supposed to extract a word randomly from the file and have the user guess the word according to the definition.

I'm having trouble matching the definition to the word from the text file.

Here's my code:

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;
int main(){
int number;
int count = 0;
string word;

[Code] ....

Here is my text file
apple#the usually round, red or yellow, edible fruit of a small tree
boat#a vessel for transport by water
horse#a solid-hoofed plant-eating domesticated mammal with a flowing mane and tail, used for riding
television#a system for transmitting visual images and sound that are reproduced on screens
soup#a liquid dish, typically made by boiling meat, fish, or vegetables, etc.
bottle#a container, typically made of glass or plastic and with a narrow neck
barber#a person who cuts hair
toast#sliced bread browned on both sides by exposure to radiant heat
radar#a system for detecting the presence, direction, distance, and speed of aircraft, ships, and other objects
red#of a color at the end of the spectrum next to orange and opposite violet

View 1 Replies View Related

C++ :: Comparing Char And Int - Output Match Or Does Not Match

Feb 21, 2013

My program compiles fine and doesn't have any errors so I am confused as to what the issue might be.

I have a int, which is determined by the user via cin.

I have a char, which is a random word generated from an input file.

1. I want the program to display "The word you entered does match..." if the word entered by the user is the same as the random word.

2. I want the program to display "The word you entered does not match..." if the word entered by the user is not the same as the random word.

The code I'm using for number one is
if (char == "int") cout << "does match..."

The code I'm using for number two is
else if (char != "int") cout << "does not match..."

Basically the programs only outputs "does not match" whether or not it really matches. Even if it matches, it outputs does not match.

Is something wrong with my code?

View 7 Replies View Related

C++ :: Creating Game Using SFML

Apr 26, 2014

I'm currently working on a 2D space shooter game in C++ using SFML library. What I need to know is how make an object (ex:laser) fire up from object (ex:player) when a user press button??

View 1 Replies View Related

C++ :: Creating Computer AI For Tic Tac Toe Game

Dec 24, 2014

How I can go about creating a computer AI given the way that I structured my code.

main.cpp

Code:
#include <iostream>
#include "Board.h"
#include <limits>
#include <cctype>
using namespace std;
int main() {
// Welcoming message.

[Code] ...

View 14 Replies View Related

C :: Creating A Kind Of Connect 4 Game

Nov 14, 2014

I'm creating a kind of connect 4 game that will be due on November 30. I'm starting now so that I don't have to worry about it as much later. Anyways, I just started, and I already have some questions/problems. I want to be able to change that numPlayers outside of the function, so I used pointers like my instructor said to, but it is giving me an error that numPlayers(the argument) is not an int*. How do I fix this?

Code:

int numPlayers=0;
void promptNumPlayers(int *numPlayers)
{
printf("Enter the number of players: ");
*numPlayers=readInt(stdin);
if (*numPlayers != 1 && *numPlayers != 2)
}

[code]...

View 3 Replies View Related

C/C++ :: Creating Moving Objects For 2D Game

Oct 21, 2014

I'm working on designing a game in C++ that is similar to the "find the ball under the cup" game. I have a Sonic the Hedgehog icon (weird I know, but it was the first thing that came to mind) that will be hidden underneath one of three rectangular blocks.

Here is how I envision this working:

On the main menu I have 3 buttons which represent 3 different difficulty levels
Easy- blocks move 3 times at a slow speed
Medium- blocks move 5 times at a slightly faster speed
Hard- blocks move 10 times at a fast speed

When the user clicks one of these buttons they will be taken to the game screen.

Sonic will be displayed for 3 seconds and the user will then see him be covered with one of the three blocks.

The three blocks will then move in a random pattern along the middle of the screen at the speed and number of times associated with the button that was pressed.

Once the blocks stop moving, the user is to click on the one they think Sonic is underneath.

If they choose correctly, they'll be taken to a "Winning Screen" that displays a congratulatory message and 2 buttons. Play Again- returns the user to the main menu and the game starts over with a new random pattern. Quit- the window closes.

If they choose incorrectly, they'll be taken to a "Losing Screen" that displays a "Try Again" message and 2 buttons that have the same function as the buttons on the winning screen.

I have never worked with any kind of graphics before other than in HTML and Javascript. I have managed to create the main menu, but how to do the actual game portion of the project. I've been trying to take it a step at a time, (for example, I first figured out how to set the background color for the console window, after I got that right I figured out how to add buttons) but the rest of this seems to depend on each other.

Here is what I have so far:

Main menu:

#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
class MainMenu

[Code]....

So I've got the screens pretty much designed now (with the exception of the game screen itself) but how to tie everything together.

In case my description wasn't too clear, here is a game that I found on Google that is pretty much exactly what I'm looking for. [URL]

View 2 Replies View Related

C/C++ :: Tic Tac Toe Game - Creating A Menu/choice

Nov 11, 2014

Im trying to create something like a menu in a tic tac toe game. I want the computer to ask the user "who starts first" is it the X or the O who starts first? Then the user should type in either X or O but if he types something else i want to ask again .

this is what ive done :

int main () {
printf("
");printf("
");
printf(" %c | %c | %c
", board[1], board[2], board[3]);

[Code] .....

View 10 Replies View Related

C++ :: Creating 2 Dimensional Console Base Game

Jun 13, 2013

what i got so for my code.

#include <iostream>
#include <windows.h>
using namespace System;
using namespace std;
int refreshDisplay(int , int);
const char wHole = '@';

[code]....

count <<" The oblective of the game is for the player to move around a 2 dimensional playing field and capture the star withought falling into a black hole or walking off the edge of the playing field. The controls are W = up S= down A=Left D=Right" <<endl; how implement 3 black hole X characters and 2 wormhole characters on field @ and a star *. all these char has to be randomly generated.

View 1 Replies View Related

C++ :: Creating A Game - Use Classes For Rendering Objects?

Mar 16, 2014

I am creating a game and I using classes for other things in my game, I was wondering if i should use classes for rendering objects?

View 2 Replies View Related

C/C++ :: Creating Two Dimensional Terminal Based Game?

Apr 4, 2014

i am working on class project in which i have to save the tank from canon....imy tank is moving only when i press the moving key.. and after that i see blank screen what should i do to run my process when i am not pressing moving keys....

View 8 Replies View Related

C# :: Creating A Class And Methods For Dice Game?

Mar 21, 2015

The only difficulty im having is creating a class and methods & being able to access them from my win form app. Can i get a few tips on the do's and donts of creating classes / methods and accessing them from form app.

This is what i have put together so far.

public partial class Form1 : Form {
private Image[] dicePics;
private int[] diceNum;
private Random randomize;
public Form1() {
InitializeComponent();

[code]....

View 3 Replies View Related

C++ :: Creating Frog Leap Game That Starts At 1 And Finishes At 12

Feb 13, 2015

I have been given the task of creating a frog leap game that starts at 1 and finishes at 12. The layout is as follows. The '@' symbols are just included to show blank white space.

1-----2 @@ 3---4
|@@ |@@@ |
|@@ |@@@ |
5@@ 6------7-----8
|@@ @@@ |@@ |
|@@ @@@ |@@ |
9----10 @ 11 @12

Each number within the game will represent an object, the user will have to reach the 12th leaf start from leaf 1. the frog can only move in the directions of forwards backwards, left and right. Any starting points? E.g. using and array or list? i have a feeling this is going to be a big task. is inheritance possible?

View 1 Replies View Related

C++ :: Creating Game That Will Test The Attention And Mind Flexibility Of User

Mar 6, 2015

I want to create a game that will test the attention and mind flexibility of the user. So the challenge is The user will be given 50 rounds, and each round should generate a random combination of text and words.Then the user must Press 'Y' if the UPPER CASE text spells out a color that match the BACKGROUND. But if the text are in LOWERCASE the user must press 'N'.(Note: you can change the keys to any key from the keyboard if you wish to)

Then I also want my program to record the high score each time the program prompts the user if he/she wishes to play again.

I also want to control the combinations by NOT allowing the text color and background color to be the same.

I also want the combination to generate an AVERAGE of 50% correct combination and 50% wrong combinations. The I want to use is only Red, Blue and Green

HIGH SCORE Determinants:

1. Accuracy ( (Number of corrects / 50 ) * 100% ) - The higher the better.
2. Time in seconds (Time Ended - Time Started) - the lower the better.

Computation for high score: 10 000 * ( (Accuracy) - (2 x total Attempts - Time) )

View 6 Replies View Related

C++ :: Spaceship Game - Creating Gravity For Each Object Depending On Mass

Mar 27, 2012

I've been having trouble working on this physics engine of mine. Right now I'm having trouble adding gravity.

The game is a spaceship--which you control--flying around in space with asteroids and eventually the ability to shoot bullets. There should be a wrap on the edges of the screen and gravity for each object depending on their mass.

I'm creating a forceX and forceY for each force put onto each object, and then computing that force into a velX and velY which will determine the direction of each object and at which speed.

Where my problem arises:

Code:
//add gravity pulls to forces
for(int i = 0; i <= pushCount; i++) //add gravity pulls for each object {
for(int u = 0 ; u <= pushCount; u++) //each object should add a force for every other object {
if(i != u) {
switch(id[i])

[Code] ....

View 7 Replies View Related

Visual C++ :: Dice Game - Creating Pass By Value Function Reference

Nov 27, 2014

i have a project where i create a dice game, the user rolls 2 dice and the computer roles 2 dice. the player that wins 3 out of 5 rolls wins the game. I have completed the requirements, but i wanted to create a pass by value function for "void Dice()", I'm not too sure how that works?

Code:

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
//creating my variables and their values
int compinput;

[Code] .....

View 5 Replies View Related

C++ :: Creating A Game - Read Prices Of Object Inputted By User From A File

Feb 19, 2013

How do i read a specific part of a file? I am trying to create a game that reads the prices of an object inputted by the user from a file. This is the code i have so far

#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream infile;
infile.open ("Objects.txt", ifstream::in);

[Code] ....

The file contains this :

Example objects
( ) store items
(item) (purchase value)/(sell value)

Grocery Store Items
Fish 5 7
Vegetables 10 15
Drinks 20 30

Weapon Store Items
Pistol 300 375
Rifle 400 500
Ammunition 20 30

View 4 Replies View Related

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 View Related

C++ :: Tic Tac Toe Game - Applying OOP And Arrays

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

C++ :: Saving Huge Arrays For Game?

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

C++ :: Creating STL Queue Of Arrays?

Dec 3, 2013

Is there any possible way to create an STL queue of arrays? I tried

queue<int[]>q;

It didn't work?

View 2 Replies View Related

C :: Creating Variable Length Arrays

Oct 24, 2014

How do you prompt the user to enter the number of elements for the array and use that information to creatr a variable length array? And then how do you prompt the user to enter in a number for each element of the array and scan in the appropriate numbers? the numbers are double precision floating point.

for example,
Enter the numbe of elements in the array: 3
Enter element 0: 3
Enter element 1: -1
Enter element 2: 4

I know it starts with

int main() {
double N;
int a[size];

printf("Enter the number of elements in the array:" );
scanf("%f", &size);

//I'm pretty sure this is wrong

View 8 Replies View Related

C/C++ :: Creating And Accessing Info From Arrays

Mar 1, 2014

I'm working on a project where I have the user enter storm data about hurricanes for multiple seasons. I need to make separate arrays for:

1. the month, wind speed, and min. press.
2. the category of the storm

What I'm having trouble understanding is how to make the software take an input, assuming from a scanf, and put it in an array. Then taking that value and output-ing it back out when needed.

So here is piece of my code. Note: Disregard the commented sections of the code, my current project is building off a previous one, where in the last project we were using loops, now we are using arrays.

case 1:
{
if (year > 0) //begins counting
{
/*num_trop_storms = 0*/ num_hurricanes = 0, year = 0, wind_speed = 0,
hcat1 = 0, hcat2 = 0, hcat3 = 0, hcat4 = 0, hcat5 = 0, hrun = 1, totalhurr = 0;
knots = 0, cummwindspeed = 0.0;

[Code] ....

In the code above, how exactly the scanf takes the inputs from the user and then stores them for me to access. So, I want my array to be 3 columns, for months , wind_speed, & minpress. The array has a undetermined amount of rows. I think if I figure out the first array, I can handle the second.

View 7 Replies View Related

C++ :: Creating Dynamic Arrays / Structures

Feb 7, 2012

We are supposed to create a menu with an option to add a car (make, model etc) to inventory. I have the structure format set up as far as adding the car, but I am stuck on how to make it a dynamic array of structures or whatnot (I'm not really sure on what I'm trying to do in the first place!) Basically, the user can choose to add a car and its info in. How do you set up the array to add whatever number of cars is needed? Will it be able to add more cars should the user come back to the program later?

This is the instruction of this portion of the project :

Menu Application
Add a car to inventory
Prompted to add
Make, Model and Year, Color, Miles, Price
Finish (adds the car to the file)
Cancel takes you to the main menu

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved