![]() |
| | #1 |
| Registered User Join Date: Aug 2004
Posts: 146
| 1) My plan is to make a small console program, where you have a space craft moving about the screen, but the problem is the control. My idea was to do this to make up movement (the other directions I haven't programmed in yet)... My idea was that I could make a basic space craft using ASCII letters (space craft not the finished product), now, the way I was going to do the control bit was to make it so that it printed an empty new line above the picture, therefore making it drop a line, also, for moving up, I was thinking of making it so that it printed a line above itself so that the space craft looked like it was moving down. This idea would then be expanded on horizontal directions, and so give control, but the problem is making it do that... Code: system ("cls");
cout << "" << endl;
cout << " | A |" << endl;
cout << " | A A |" << endl;
cout << " AAAAAA" << endl;
cin >> a;
if(a == 1)
{
cout << "" << endl; \\This line of code needs to be
\\shown above the space craft
}
else if(a == 2)
{
}
|
| Finchie_88 is offline | |
| | #2 |
| Code Goddess Join Date: Sep 2001
Posts: 9,664
| I make no guarantees as to whether this will work for you, I made two big assumptions about your system and compiler. ![]() Code: #include <cstdlib>
#include <iostream>
#include <string>
#include <conio.h>
#include <windows.h>
using namespace std;
void gotoxy ( short x, short y )
{
COORD coord = {x, y};
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
}
void draw_ship ( short x, short y )
{
gotoxy ( x, y );
cout<<"| |";
gotoxy ( x, ++y );
cout<<"|=[@]=|";
gotoxy ( x, ++y );
cout<<" ^ ";
}
void redraw ( short x, short y )
{
system ( "cls" );
draw_ship ( x, y );
}
int main()
{
short x = 10, y = 10;
while ( y > 0 && y < 17 && x > 0 && x < 20 ) {
redraw ( x, y );
switch ( getch() ) {
case 'w': --y; break;
case 's': ++y; break;
case 'a': --x; break;
case 'd': ++x; break;
}
}
}
__________________ My best code is written with the delete key. |
| Prelude is offline | |
| | #3 |
| Registered User Join Date: Aug 2004
Posts: 146
| sorry, but I having a bit of difficulty making it so that you can shoot on the game... I need tips/helpful advice/example code/hyperlinks etc... |
| Finchie_88 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Button handler | Nephiroth | Windows Programming | 8 | 03-12-2006 06:23 AM |
| Type Of Memory In A Control? | SMurf | Windows Programming | 4 | 03-04-2006 12:23 PM |
| RickEdit control question | nomer | Windows Programming | 6 | 03-03-2006 07:00 PM |
| creating an activex control | Benzakhar | Windows Programming | 9 | 12-29-2003 06:32 PM |
| Control class | Mithoric | Windows Programming | 0 | 11-28-2003 08:35 AM |