Jump to content

Finally

- - - - -

  • Please log in to reply
7 replies to this topic

#1
Waqar

Waqar

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts
finally i hav made this program after too much hard work here it is



ROCKET(MAKE MOVEMENT ON SCREEN)



#include<stdio.h>

#include<conio.h>

#include<string.h>

#define ROW 24

#define COL 9

#define height 25

void main(void)

{

  clrscr();

  char str[ROW][COL] = {{0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,0,0,0,0,0},

		       {0,0,0,0,'\x1E',0,0,0,0},

		       {0,0,0,'\x1E','\xDB','\x1E',0,0,0}};



  char *ptr[ROW],*temp;                            //pointer pointing to array

  for(int m=0;m<ROW;m++)

  *(ptr+m)= *(str+m);				


				     //repeating the whole process

  for(int out=0;out<ROW-1;out++)

	  {

                                                            	 //print rocket

       for(int i=0;i<ROW;i++)

	  {


	   for(int j=0;j<COL;j++)

	      printf("%c",*(*(ptr+i)+j));

	   printf("\n");


	   }


	                          			//starting line/ ground

       for (int k=0;k<COL;k++)

	   printf("%c",'\xCB');



	 temp=*ptr;

	 for(int l=0;l<ROW-1;l++)

	     *(ptr+l)=*(ptr+l+1);

	 *(ptr+ROW-1)=temp;

	 char ch=getch();

	 if(ch==0)

	   getch();

	 clrscr();



	 }


}
Now i wanna make it a full screen program and also i want to make it move left,right and downwards can u guys help me by giving me some help full ideas plz
thanks in advance:thumbup:

Edited by Roger, 11 August 2011 - 07:28 AM.

LOve To BE A PRoGramER:rules:

#2
artificial

artificial

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 624 posts
First of all, please use code-tags. They make your post much more readable. ;)

I don't know whether there is a real option to switch your program to fullscreen-mode. The problem is that you're most probably running it on an operation system like Windows. Consequently, the terminal in which your program runs is just emulated. I'd recommend to use a library like Allegro or SDL.

Greets,
artificial
Sometimes words ain't enough to express something. That's why computer scientists use double words.

#3
haltox

haltox

    Newbie

  • Members
  • PipPip
  • 29 posts
If you still want to do it in console, you should make an abstraction layer(in your case, probably a function) that will take care of 'drawing' the ship to it's position in the array. Then, you jsut have to update it's position, call the function and display it in console.

It would probably look like this

void drawShip(int x, int y,char[][] grid){

   //loop over the array to draw the ship at its position(the nose or center of the ship at grid[x][y])

}



#4
Kuto

Kuto

    Learning Programmer

  • Members
  • PipPipPip
  • 49 posts
In Windows Xp, "Alt + Enter" key combination makes console full screen. You can simply simulate it. As far as i know Windows Vista and 7 don't support full screen consoles. You can(must) use a graphic library.

#5
Waqar

Waqar

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts
lmao i wasnt meant that kind of full screen,lol i know alt+enter do it
this program got an array of 24x9 i was asking that should i take this array 80x25 or 25x80 to make this like a game
and other question was how can i make rocket move left and right by using pointer i can shuffle rows in this array my question is can i shuffile between columns? so by using my arrow keys i can make rocekt move in all 4 directions of the screen edge to edge:-P
LOve To BE A PRoGramER:rules:

#6
Kuto

Kuto

    Learning Programmer

  • Members
  • PipPipPip
  • 49 posts

Waqar said:

lmao i wasnt meant that kind of full screen,lol i know alt+enter do it
What is that so funny? Watch your mouth first of all!

#7
haltox

haltox

    Newbie

  • Members
  • PipPip
  • 29 posts
You'd have to use a framework like sdl to so. However I'm not quite sur how to mix intercepting keyboard signals vs working out with the console would work

#8
Waqar

Waqar

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts

Quote

What is that so funny? Watch your mouth first of all!


dude u r too rude try to be polite we all r here to learn well idk abt others bt i m and i was jst trying to be frank like frnds bt if u dont want that frm me so dont rply to my posts simply:mad:
LOve To BE A PRoGramER:rules:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users