I feel so proud

Steven

Newbie
Joined
Sep 18, 2005
Messages
1,908
Reaction score
0
I have finally programmed my first ever Computer game. :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce:
 
back in the day I had to code computer games on my abacus
 
I realy cant be botherd hosting it but I'll just post the source code.

Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
  int player = 10;
  
  int NPC = 10;
  
  int attack1;
  cout << "Welcome to battle!\nTo attack press 1\nTo block press 2.\n";
  cin >> attack1;

  if (attack1 == 1)
  {
    for (;;)
    {
      if (attack1 == 1)
      {
        NPC = NPC - 2;
        player = player - 3;
        cout << "ATTACK!\nYou attacked and lost 3HP.\nThe NPC lost 2HP from your attack\nYou have "
             << player
             << "HP.\nThe NPC has "
             << NPC
             << "HP.\nTo attack press 1\nTo block press 2.\n";
    
        int attack2a;
        cin >> attack2a;
    
        if (attack2a == 1)
        {
          NPC = NPC - 2;
          player = player - 3;
          cout << "ATTACK!\nYou attacked and lost 3HP.\nThe NPC lost 2HP from your attack\nYou have "
               << player
               << "HP.\nThe NPC has "
               << NPC
               << "HP.\nTo attack press 1\nTo block press 2.\nOr to run away press 3.\n";
        }
      
        if (attack2a == 2)
        {
          player = player - 2;
          cout << "Your block was somewhat effective and you only lost 2HP as opposed to 3HP.\nYou have "
               << player
               << "HP\nThe NPC has "
               << NPC
               << "HP.\nIt is no longer possible to win with the current scores.";
          break;
        }
      
          int attack3a;
          cin >> attack3a;
          
          if (attack3a == 3)
          {
            cout << "You run away and the NPC runs out of breath and loses.\nYou have won, thank you for playing.\nProgrammed by Steven C. Berry.\n";
            break;
          }
      
          if (attack3a == 1)
          {
            NPC = NPC - 2;
            player = player - 4;
            cout << "ATTACK!\nYou attacked and lost 4HP.\nThe NPC lost 2HP from your attack\nYou have "
                 << player
                 << "HP.\nThe NPC has"
                 << NPC
                 << "HP\nYou have lost better luck next time.\n";
            system("PAUSE");
            break;
          }
          if (attack3a == 2)
          {
            player = player - 4;
            cout << "BLOCK!\nYour attack was useless and you lost 4HP.\nThe player has "
                 << player
                 << "HP.\nThe NPC has "
                 << NPC
                 << "HP.\nYou have lost better luck next time.\n";
            break;
          }
        }
      }
    
      system("PAUSE");
      return 0;
    }
  }
}
T'is very basic and the only way to win is by pressing 3 to run away when it asks you.
 
theSteven said:
I realy cant be botherd hosting it but I'll just post the source code.

Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
  int player = 10;
  
  int NPC = 10;
  
  int attack1;
  cout << "Welcome to battle!\nTo attack press 1\nTo block press 2.\n";
  cin >> attack1;

  if (attack1 == 1)
  {
    for (;;)
    {
      if (attack1 == 1)
      {
        NPC = NPC - 2;
        player = player - 3;
        cout << "ATTACK!\nYou attacked and lost 3HP.\nThe NPC lost 2HP from your attack\nYou have "
             << player
             << "HP.\nThe NPC has "
             << NPC
             << "HP.\nTo attack press 1\nTo block press 2.\n";
    
        int attack2a;
        cin >> attack2a;
    
        if (attack2a == 1)
        {
          NPC = NPC - 2;
          player = player - 3;
          cout << "ATTACK!\nYou attacked and lost 3HP.\nThe NPC lost 2HP from your attack\nYou have "
               << player
               << "HP.\nThe NPC has "
               << NPC
               << "HP.\nTo attack press 1\nTo block press 2.\nOr to run away press 3.\n";
        }
      
        if (attack2a == 2)
        {
          player = player - 2;
          cout << "Your block was somewhat effective and you only lost 2HP as opposed to 3HP.\nYou have "
               << player
               << "HP\nThe NPC has "
               << NPC
               << "HP.\nIt is no longer possible to win with the current scores.";
          break;
        }
      
          int attack3a;
          cin >> attack3a;
          
          if (attack3a == 3)
          {
            cout << "You run away and the NPC runs out of breath and loses.\nYou have won, thank you for playing.\nProgrammed by Steven C. Berry.\n";
            break;
          }
      
          if (attack3a == 1)
          {
            NPC = NPC - 2;
            player = player - 4;
            cout << "ATTACK!\nYou attacked and lost 4HP.\nThe NPC lost 2HP from your attack\nYou have "
                 << player
                 << "HP.\nThe NPC has"
                 << NPC
                 << "HP\nYou have lost better luck next time.\n";
            system("PAUSE");
            break;
          }
          if (attack3a == 2)
          {
            player = player - 4;
            cout << "BLOCK!\nYour attack was useless and you lost 4HP.\nThe player has "
                 << player
                 << "HP.\nThe NPC has "
                 << NPC
                 << "HP.\nYou have lost better luck next time.\n";
            break;
          }
        }
      }
    
      system("PAUSE");
      return 0;
    }
  }
}
T'is very basic and the only way to win is by pressing 3 to run away when it asks you.

So it's pretty much an algorithm where pressing 3 breaks you out of the "OMFG PWNED" cycle?

Tis simple, but looks interesting.

The begginings of a [hopefully] great game designer.

:cheers:
 
So it's pretty much an algorithm where pressing 3 breaks you out of the "OMFG PWNED" cycle?

Tis simple, but looks interesting.

The begginings of a [hopefully] great game designer.
Yeah not really Half-Life 2 but it's still a game and thanks.
 
Nice one!

I've made a few simple games/programs myself now:

TicTacToe
Minesweeper
Sudoku solver

And I've been researching some stuff on DirectDraw. I've had a few stabs at 3D programming too, but I think thats one leap too far for the time being, I'm going to try and make my own Space Invaders clone. I've read some books on game engine designs from when I was looking at 3D programming, so I can use the components in there as a basis xD
 
My first game was a Tic-Tac-Toe
Re-Made is using several different techniques in C++.
2 people would type their names. Would tell who had to go. Wouldn't let you go in the same spot twice, detect who wins, ask for a restart, etc..
 
lost :frown:

good stuff though, just finished making shit breakout clone for college last week
 
Back
Top