Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

My C++ Console Shooter


JeffSventora
 Share

Recommended Posts

There's no proper place for introductions, so I figured I would do it here with a look at little game I programmed in C++. My name is Jeff, some may know me as Jsventor (although I seriously doubt it). I started working with Mirage based engines YEARS ago and then eventually gave it a break to further enhance my programming skills.

Below are some screen shots of the game I created. It is VERY simple but still uses some advanced techniques like the implementation of doubly linked lists, polymorphism, bitwise operation/manipulation, queues, and some of the FCL's built in functions. I would have never thought that some of these techniques would ever be used in a console program. but here I am.

Not exactly sure what I was thinking, but you play as a Wizard shooting fireballs at an Orc… in space. Killing the Orc will give you one point towards your score, the more you kill him, the more intense his AI becomes.

Download
[Click Me!](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=73012.0;attach=18695)

**Controls**
**W,A,S,D:** Move Avatar
**Left, Down, Right, Up Arrows:** Shoot Fireballs
**F1:** Toggle Enemy Visibility
**F2:** Toggle Player Visibility
**F3:** Toggle Enemy Movement
**F4:** Toggle Enemy Ability to Fire

Beware, your shots will bounce ONCE upon impact with the sides of the console, you CAN kill yourself.
Link to comment
Share on other sites

@D.J.:

> Could you give a download link to some of us that know how to run a console application and are interested in playing your game??? Oh and it looks great by the way.

Download link provided in the topic post. Look at the bottom of the post for controls and in the attachments for the zip. And thank you :)
Link to comment
Share on other sites

I'll test it this afternoon when i am on my computer. I am busy learning C at the moment and hope to create something like this soon. And like Relly said, would it be possible for you to release the source code??? Since this is your first post welcome to the community.
Link to comment
Share on other sites

Yeah, like I said, I will surely work on a completely different release with better optimization and more comments for you're guy's disposal. Just give me some time and I'll whip something cool up for you guys.

Take note, D.J, I programmed this using the Framework Class Library in Windows, since you're using C I am honestly unsure of what accessibility you have, but hell, us programmers are good at figuring stuff out ^^

@Robin, I started with Elysium years back, from there I followed "frozengod" to the Chaos forums (I'm sure you remember that). Then from there I migrated to Mirage and stayed there until it died and Mirage Realms picked up, I was a moderator there for a bout a week until that also died. I surely do remember you though! :p
Link to comment
Share on other sites

In a **CLR** application make sure you have:
```
using namespace System;
```
```
Console::SetWindowSize(80, 30);
Console::SetBufferSize(Console::WindowWidth, Console::WindowHeight);
```
The max width is 80, going beyond will cause an error, I am not sure what the max height is though.
Link to comment
Share on other sites

It works pretty cool except:

The score system gives you points even if you not doing anything.
If you leave the score running long enough it will start going into the negatives.
You have to keep on retyping \build3.exe to restart it so maybe a restart function?
What's the difference between the colours that you are?

Anyway it looks great.

Regards,
  Dewald
Link to comment
Share on other sites

Well the reason why the score is doing that is because initially the enemy is "dead" until you use the hotkey to bring him in. The reason why that happens is because I was just practicing with Bit Flags. Also the reason why it goes into the negatives is because the score will reach INT_MAX and then fold over into the greatest negative value. As far as the colors, they don't do anything special, but if you want, in the text files you can actually edit the pictures used in game. I basically created "Images" using text. Just make sure on the last line there is a tab and that you don't mess with the numeric values included. Thanks for the comments!
Link to comment
Share on other sites

Hey guys, for those interested in getting a sneak peek at how I did things, I uploaded the header file (.h) for my Image class. Look in the main post's attachment section at the bottom, just above my signature.

To use it, open up a new CLR Application in VS 2010, insert the _Image.h_ to your project. Open up _stdafx.h_ and insert the following code:

```
#include #include #include
```
Go into your Main.cpp and add the include for _Image.h_ (#include "Image.h"). Then in your main function add the following code:

```
CImage test;
test.ShowImage();
```
Everything should be working just fine. If it is, you will see a pink critter with antennas and a body. For the game I showed off, I created another class "CSprite" which inherits the Image class, I just added variables for velocity and position to move it around. As far as events for Key Presses, all you need to do is create an Infinite loop. In the loop you use the following code:

```
if(GetAsyncKeyState(VK_ESCAPE))
{
    break;
}
```
That code will exit the infinite loop is the user hits 'Escape'. So I did that but added a check for all of the arrows and the **WASD** keys as well to move the player's avatar.

If you have any further questions, feel free to ask away :p
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...