Jump to content
  • Advertisement
Sign in to follow this  
Saad Zafar

Candy Crush type game in C

This topic is 2067 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,
I'm a first semester student of Programming and I have an assignment where I have to design a game somewhat like candy crush, called number crush where instead of candy, when 3 numbers are aligned, you get a point. and the numbers disappear.

I have to use C to design the game.
can anyone please help me?

Share this post


Link to post
Share on other sites
Advertisement

we were given an .exe file and were told to model our game on it.
can you check the game out and assist me in writing the code for it?
 

Share this post


Link to post
Share on other sites

We were just given a compiled C code in .exe format and a word file explaining vaguely what to do and we were asked to model our game on it.
I've only gotten as far as the code i've shown below.

#include <time.h>
#include <math.h>
#include <stdio.h>
#include <conio.h>
#define ROW 10
#define COL 10
int x,y;

int main()
{
 int r=1;
 int arr[ROW][COL];
 char name[20];
 printf("-------NUMBER CRUSH-------\n***************************\n\n");
 printf("Enter your name: ");
 scanf("%c", &name);
 system("cls");
 r=1;
 while(r=1)
 {
  printf("-------NUMBER CRUSH-------\n***************************\n\n");
  printf("Welcome %c, LET'S PLAY!!\n\n", name);
  initialize(arr);
  printf("\n\n");
  printf("to regenerate the array press 1: ");
  scanf("%i", &r);
  system("cls");
 }
 return 0;
}

/*define grid and populate with random numbers and print to screen*/
int initialize(int grid[ROW][COL])
{
 int n;
 srand(time(NULL));
 for(x=0;x<10;x++)
 {
  for(y=0;y<10;y++)
  {
   n=2+rand()%7;
   grid[x][y]=n;
   printf("%d    ", n);
  }
  printf("\n\n\n");
 }
 return 0;
}

Share this post


Link to post
Share on other sites

i do not want you to write the entire code, just guide me in the right direction.
I will post new portions of the code as i'm done writing them and I would appreciate it if you could take a look and point me in the right direction.

can you do that?

Share this post


Link to post
Share on other sites
 r=1;
 while(r=1)
 {
  printf("-------NUMBER CRUSH-------\n***************************\n\n");
  printf("Welcome %c, LET'S PLAY!!\n\n", name);
  initialize(arr);
  printf("\n\n");
  printf("to regenerate the array press 1: ");
  scanf("%i", &r);
  system("cls");
 }

right now i'm having trouble with this portion of the code.
the loop is only supposed to work if i press 1, otherwise if i press anything else it should terminate but that is not happening.
can you tell me where i'm going wrong?

Share this post


Link to post
Share on other sites

also i can not get the 1D array called name to store the complete string.
it is supposed to store the complete string which is entered using the scanf command and stored in the name array

it just displays some random ASCII character instead of the whole string.
what am i doing wrong here?

char name[20];
printf("-------NUMBER CRUSH-------\n***************************\n\n");
printf("Enter your name: ");
scanf("%c", &name);
system("cls");
r=1;
while(r=1)
{
printf("-------NUMBER CRUSH-------\n*************

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!