
C is one of the oldest but though the powerful language. C has influenced many software jobs in the world. As a Computer Engineering student I also started with C and I simply loved it coz it does everything I wanted to as of my code. I Developed games using C in TC using 'graphics.h'. It was fun doing the GUI with C
Here I want to share one of my game codes.
The concept of the code is not taken from any existing game and is fully new.

SNAPSHOT OF PUSHBOX
Rules
- Movement of Hero is done by using keys w as up, a as left, s as down, d as right.
- Hero is restricted through walls ans Xs.
- Hero can push only one object at a time.
- Remember only pushing is possible pulling is restricted
- When you push box in hurdles both the object and hurdles will disappear and the position acquired by X before pushing will become free space.
- At any stage to Quit press o.
- To restart press r.
- Play keeping caps lock off.
/*
Author: Roshan Kedar
Compatibility: Win XP and before, Win7 32 bit (somewhat unstable)
*/
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void display(char a[11][9]);
int pos(char a[11][9]);
void swap(char *a,char *b);
int final(char a[11][9]);
void main()
{
char a[11][9],ch;
for(i=0;i<11;i++)
for(j=0;j<9;j++)
a[i][j]='a';
}
{
a[i][8]='H';
for(i=0;i<9;i++)
a[0][i]='H';
}
{
{
a[i][j]='H';
}
a[1][7]='X';
a[9][7]='X';
a[4][5]='U';
a[6][5]='U';
a[1][2]='H';
a[1][6]='H';
a[7][2]='H';
a[7][6]='H';
/* You can change the designing part to customize your own puzzle
*/
abc:;
final1=final(a);
if(final1==0)
clrscr();
printf("\\n\\n********Congrats Puzzule
Solved********");
clrscr();
upos=pos(a);
no=ch;
{
{
{
a[2][1]='O';
goto abc;
else
if(a[2][7]=='U'&&a[3][7]=='O')
a[1][7]='a';
a[3][7]='a';
}
goto
abc;
goto
abc;
{
swap(&a[upos/9][upos%9],&a[(upos/9)-1][upos%9]);
else
if(a[(upos/9)-1][upos%9]!='X')
}
}
{
{
{
a[8][1]='O';
}
{
a[8][7]='O';
}
goto
abc;
goto
abc;
{
swap(&a[upos/9][upos%9],&a[upos/9+1][upos%9]);
else
if(a[(upos/9)+1][upos%9]!='X')
}
}
{
{
{
a[1][6]='O';
}
{
a[9][6]='O';
}
goto
abc;
goto
abc;
{
swap(&a[upos/9][upos%9],&a[upos/9][upos%9+1]);
else
if(a[(upos/9)][upos%9+1]!='X')
}
}
{
{
{
a[1][2]='O';
}
{
a[9][2]='O';
}
goto
abc;
goto
abc;
{
swap(&a[upos/9][upos%9],&a[upos/9][upos%9-1]);
else
if(a[(upos/9)][upos%9-1]!='X')
}
}
{
}
else if(no==114)
{
goto ab;
}
goto abc;
}
getch(); /* clean up */
closegraph();
}
void display(char a[11][9])
{
int poly[8];
{
{
{
poly[1]=poly[3]=y1;
poly[7]=poly[5]=y2;
setfillstyle(SOLID_FILL,RED);
}
{
poly[1]=poly[3]=y1+3;
poly[7]=poly[5]=y2-3;
setfillstyle(SOLID_FILL,YELLOW);
}
{
poly[1]=poly[3]=y1+3;
poly[7]=poly[5]=y2-3;
setfillstyle(SOLID_FILL,BLACK);
}
{
poly[1]=poly[3]=y1+3;
poly[7]=poly[5]=y2-3;
setfillstyle(SOLID_FILL,CYAN);
}
{
poly[1]=poly[3]=y1;
poly[7]=poly[5]=y2;
setfillstyle(SOLID_FILL,GREEN);
}
x2=x2+20;
x1=100;
y1=y1+20;
}
}
int pos(char a[11][9])
{
for(i=1;i<11;i++)
for(j=1;j<9;j++)
if(a[i][j]=='O')
pos=9*i+j;
}
}
}
void swap(char *a,char *b)
{
temp=*a;
*b=temp;
}
int final(char a[11][9])
{
{
{
{
return(final);
}
return(final);
}
|
This page was last modified on 22 Jul 2011 at 12:06:31. |
Roshan Kedar Student rosdreambinary.blogspot.com |
» C program to generate the Fibonacci series
» C program to print a semicolon without using a semicolon
» C program to compare two strings without using strcmp
» C program to concatenate two strings without using strcat
» C program to delete a specified line from a text file
» C program to replace a specified line in a text file
» C program to find the number of lines in a text file
» C program which asks the user for a number between 1 to 9
» C program to check whether the given string is a palindrome
» C program to check whether the given number is a palindromic
» C program to find factorial of the given number
» C program to check whether the given number is even or odd
» C program to swap two numbers using a temporary variable
» C program to swap two numbers using bitwise operators
» C program to find the greatest of three numbers
» C program to find the greatest among ten numbers
» C program to check whether the given number is a prime
» How to create pyramid in c
» Fun with C language.
