It would have been if I could have seen the source... and it was a dos app using graphics.h
It would have been if I could have seen the source... and it was a dos app using graphics.h
What is C++?
>> How can I make it move faster??
instead of:
y--,
y++,
x-- AND
x++
try:
y-=5,
y+=5,
x-=5 AND
x+=5
"There are three kinds of people in the world...
Those that can count and those that can't."
here's a link to a pacman game that uses bgi:
http://www.planet-source-code.com/vb...=3031&lngWId=3
It's from planet-source-code.com
i thought you couldnt use BGI in windows...am i wrong?
how can u make it move by itself
you know like if you hit down key move down untill other direction pressed?!
Nope BGI is not in windows...
You have to make your target project a DOS app.
To make it move by itself just do like this:
its something like that... I cant get to my source right noe though.Code:x=250; y=400; for (/*your loop stuff here*/){ circle ( x, y, 10 ); y++ }
What is C++?
I have started a space shooter game (like galaga).
Its called Sonic Space. I have th "map" and the "players ship" set up... and it moves side to side. (I finally figured out that y += 5 instead of y++ on my own) now I need to make bullets and bad guys... and make the badguys shoot and make stuff blow up when its hit...
What is C++?
I am coding a sniper game using Turbo C++ 3 and BGI. I have alot of it done already, I just need to make it so the crosshair doesn't go off the screen and I need to make targets for you to shoot at. I will gladly share the source when it is more complete.
gcc -lalleg
http://www.ciusa.net/~jrgrant/
I remember you were having problems with keyboard input earlier, so I will post what I have done:
You may need to change the initgraph() function so that the BGI part points to the right location, then it should compile. Again I used Turbo C++ 3.0
[edit]By the way, I know the up and down keys are flipped, that is easily fixed.[/edit]
gcc -lalleg
http://www.ciusa.net/~jrgrant/
Bullets.. this is just a guess.
Code:. . . case 's': bullet(); break; . . . void bullet() { circle ( x, y, 1 ); for() { delay(30); y++; } }
Last edited by Vicious; 05-30-2002 at 02:36 PM.
What is C++?
there is what I have so farCode:#include <iostream.h> #include <graphics.h> #include <conio.h> int GraphicsDriver; int GraphicsMode; int x = 300; int y = 430; int quit = 0; int mve; int main() { initgraph ( &GraphicsDriver, &GraphicsMode, "c:\\bc5\\bgi" ); while ( !quit ) { gotoxy(1,1); cout << "X: " << x << " Y: " << y; settextstyle ( 1, HORIZ_DIR, 2 ); setcolor(RED); outtextxy ( 230, -5, "Sonic Space" ); setcolor (BLUE); rectangle ( 140, 20, 440, 470 ); mve = getch(); switch ( mve ) { case 'd': if( x != 430 ) x += 5; break; case 'a': if( x != 150 ) x -= 5; break; case 'q': quit=1; break; } cleardevice(); setfillstyle ( SOLID_FILL, BLUE ); setcolor (RED); pieslice ( x, y, 240, 300, 15 ); } closegraph(); return 0; }
What is C++?
none of the codes move by itself!?
what you mean?
any way after someone tells me bout the bullets.. how about being able to move and shot at the same time?
What is C++?
I added some more to my code, alot of stuff is wrong right now, if you try you can move the cursor off the screen to the right and bottom. The bullets stay of the screen. I think I need to redesign it. I need a linked list of bullets I guess. Then I need a different way to control it. Right now I have processinput() that moves the crosshair and all, but it stays in that function untill you hit escape, I need to code a processinput that gets passed the input and does stuff based on it, so I can use it for more than just moving the crosshair and drawing bullets. I also need to make moving the crosshair less jumpy. I think I should change all the if statements in processinput() to a switch statement.
Code:// sniper.cpp // A weak ass sniper game by Josh Grant // [email protected] // // Compiled using Turbo C++ 3.0 #include <graphics.h> #include <conio.h> #define ESC_KEY 27 #define SPACE_KEY 32 #define UP_KEY 72 #define RIGHT_KEY 77 #define DOWN_KEY 80 #define LEFT_KEY 75 void intro(); // Shows the intro to the game void setup(); // Sets graphics mode void desetup(); // Resets graphics mode and shows game credits void drawcrosshair(int x, int y); // WTF do you think? :) void erasecrosshair(int x, int y); // This draws the crosshair, but in black, so it erases it void fire(int x, int y); // Draws a bullet, or a small explosion, well, just some dots void processinput(); // When you hit a key, the crosshair moves, :) int main() { setup(); intro(); processinput(); desetup(); return 0; } void intro() { setcolor(RED); settextstyle(4, 0, 8); outtextxy(200, 100, "Sniper"); settextstyle(0, 0, 1); outtextxy(200, 250, "Welcome to sniper, ready to hunt?"); outtextxy(200, 300, "Hit any key to start..."); getch(); cleardevice(); } void setup() { int graphdriver = 9; int graphmode = 2; initgraph(&graphdriver, &graphmode, "c:\\tc\\bgi"); } void desetup() { closegraph(); } void drawcrosshair(int x, int y) { // First we draw two lines, to make the + part setcolor(RED); // vertical line line(x, y+50, x, y-50); // horizontal line line(x-50, y, x+50, y); // circle circle(x, y, 35); } void erasecrosshair(int x, int y) { setcolor(BLACK); // All we are doing is drawing a cross hair, but making it black so it dissapears // First we draw two lines, to make the + part // vertical line line(x, y+50, x, y-50); // horizontal line line(x-50, y, x+50, y); // circle circle(x, y, 35); } void fire(int x, int y) { setcolor(CYAN); circle(x, y, 1); circle(x, y, 2); circle(x, y, 3); circle(x, y, 4); } void processinput() { int x = 60, y = 60; drawcrosshair(x, y); int theinkey = 0; while(theinkey != ESC_KEY) { if(theinkey == SPACE_KEY) fire(x, y); if(theinkey == UP_KEY && y > 61) { erasecrosshair(x, y); y -= 25; drawcrosshair(x, y); } if(theinkey == RIGHT_KEY) { erasecrosshair(x, y); x += 25; drawcrosshair(x, y); } if(theinkey == DOWN_KEY) { erasecrosshair(x, y); y += 25; drawcrosshair(x, y); } if(theinkey == LEFT_KEY && x > 61) { erasecrosshair(x, y); x -= 25; drawcrosshair(x, y); } theinkey = getch(); } }
gcc -lalleg
http://www.ciusa.net/~jrgrant/
wow!
very nice... i love your comments :P
can you explain on making bullets?
What is C++?