Go Back   Champions of Regnum > English > The Inn

The Inn A place to gather around and chat about almost any subject

Reply
 
Thread Tools Display Modes
Old 10-26-2010, 12:12 PM   #11
Raideniza
Apprentice
 
Raideniza's Avatar
 
Join Date: Dec 2009
Location: Алсиус
Posts: 85
Raideniza is on a distinguished road
Default

Quote:
Originally Posted by surak View Post
OMG you're right (?)

Maybe I should open an OpenGL performance thread and we all try to figure out what's the issue, because I couldn't find it.
wow, i guess new community manager's influence on ngd staff is starting to show. what a great idea that is surak, i wonder why i havent thought of it :/

oh and

Code:
exit 0;
Raideniza no ha iniciado sesión   Reply With Quote
Old 10-26-2010, 12:17 PM   #12
kidanger
Pledge
 
Join Date: Aug 2007
Location: France
Posts: 4
kidanger is on a distinguished road
Default

Quote:
Originally Posted by Znurre View Post
For example your getter methods
Usually in C++, people use camel case method names without a first capital letter.
However, in all Microsoft's .NET languages, method names (and properties) starts with a capital letter.
My methods names came from my C++ book

Damn, .NET ! I will have to change my habits…
kidanger no ha iniciado sesión   Reply With Quote
Old 10-26-2010, 12:18 PM   #13
surak
Legend
 
surak's Avatar
 
Join Date: Mar 2006
Location: Oslo
Posts: 2,176
surak has a spectacular aura aboutsurak has a spectacular aura about
Default

Quote:
Originally Posted by Raideniza View Post
wow, i guess new community manager's influence on ngd staff is starting to show. what a great idea that is surak, i wonder why i havent thought of it :/

oh and

Code:
exit 0;
I can't do everything at once
__________________
Surak Remember... this is just a game! - Xephandor existe y Miriya es su profeta!
surak no ha iniciado sesión   Reply With Quote
Old 10-26-2010, 02:29 PM   #14
Raideniza
Apprentice
 
Raideniza's Avatar
 
Join Date: Dec 2009
Location: Алсиус
Posts: 85
Raideniza is on a distinguished road
Default

Quote:
Originally Posted by surak View Post
I can't do everything at once
baw but i thought you're that party god with fiery hair :S
Raideniza no ha iniciado sesión   Reply With Quote
Old 10-27-2010, 09:33 AM   #15
Arafails
Baron
 
Arafails's Avatar
 
Join Date: Nov 2007
Location: Not where it looks like, to either of us.
Posts: 706
Arafails will become famous soon enough
Default

main.cpp:
Code:
#include <iostream>

#include "player.hpp"
#include "mob.h"

int main( int argc, char **argv )
{
   std::cout << "Hello Ra !" << std::endl;
   std::cout << "Enter your player name: ";
   
   char name[ 32 ];
   std::cin >> name;
   Player player(name);
   player.punish();
   new Mob(player.getLevel() + 5).attack(player)
}
player.hpp:
Code:
#ifndef PLAYER_HPP
#define PLAYER_HPP

#include <iostream>
#include <cstdlib> //rand()

class Player
{
   public:
      Player();
      Player(char* n) : banned( false ), level( 1 ) { name = n; }
      
      std::string GetName() { return name; }

      void punish()
      {
	 //TODO
	 if(rand()%3 == 2)
	 {
	    std::cout << "Hacker detected. " << name << " is now banned." << std::endl;
	    banned = true;
	 }
      }

      unsigned int getLevel()
      {
         return level;
      };
   
   private:
      std::string name;
      bool banned;
      unsigned int level;
};

#endif
mob.h:
Code:
#ifndef __MOB_H
#define __MOB_H
#include "player.hpp" /* Note to author: please separate implementation from headers, no one likes
                      * to compile a module for file that includes its headers */

class Mob {
  public:
    Mob(unsigned int level);
    void attack(Player player);
}
#endif
mob.cpp:
Code:
#include "mob.h"

Mob::Mob(unsigned int level)
{
}

void Mob::attack(Player player)
{
}
Edit: I have a bug.... Okay I fixed it myself.
__________________
If you can't detect sarcasm yourself, please pay attention when it's pointed out to you.
Arathael :: Wyrd Sceote :: Gwn M'gerSoul Taker, Imperial Guard of Ignis

Last edited by Arafails; 10-27-2010 at 10:07 AM.
Arafails no ha iniciado sesión   Reply With Quote
Old 10-27-2010, 10:50 AM   #16
Znurre
Marquis
 
Join Date: Jan 2007
Location: RA
Posts: 1,897
Znurre will become famous soon enoughZnurre will become famous soon enough
Default

main.cpp:
Code:
#include <iostream>

#include "player.hpp"
#include "mob.h"

int main( int argc, char **argv )
{
   std::cout << "Hello Ra !" << std::endl;
   std::cout << "Enter your player name: ";
   
   char name[ 32 ];
   std::cin >> name;
   Player player(name);
   player.punish();
   
   if( !player.isBanned() )
      Mob(player.getLevel() + 5).attack(player);
}
player.hpp:
Code:
#ifndef PLAYER_HPP
#define PLAYER_HPP

#include <iostream>
#include <cstdlib> //rand()

class Player
{
   public:
      Player();
      Player(char* n) : banned( false ), level( 1 ) { name = n; }
      
      std::string GetName() { return name; }

      void punish()
      {
         std::cout << "<chilko> ban time!" << std::endl;
    
           //TODO
         if(rand()%3 == 2)
         {
            std::cout << "Hacker detected. " << name << " is now banned." << std::endl;
            banned = true;
         }
      }

      unsigned int getLevel()
      {
         return level;
      };
      
      bool isBanned()
      {
         return banned;
      }
   
   private:
      std::string name;
      bool banned;
      unsigned int level;
};

#endif
mob.h:
Code:
#ifndef __MOB_H
#define __MOB_H
#include "player.hpp" /* Note to author: please separate implementation from headers, no one likes
                      * to compile a module for file that includes its headers */

class Mob {
  public:
    Mob(unsigned int level);
    void attack(Player player);
};
#endif
mob.cpp:
Code:
#include "mob.h"

#include <iostream>

Mob::Mob(unsigned int level)
{
}

void Mob::attack(Player player)
{
  std::cout << player.GetName() << " was attacked by a vicious creature!" << std::endl;
}
Sorry Ara, had to change some small things to get it to compile
__________________
Winning a fight is not what makes you a good player, it's how you do it.
http://home.znur.re/screenshot%20201...2011_39_37.jpg
Znurre no ha iniciado sesión   Reply With Quote
Old 10-27-2010, 11:50 AM   #17
Masterkick
Baron
 
Masterkick's Avatar
 
Join Date: Aug 2007
Location: Gallifrey
Posts: 718
Masterkick will become famous soon enoughMasterkick will become famous soon enough
Default

Hehe... I think we should compile this every 15 posts, just to see what (for normal human beings) this is mutating to.
__________________
Runi
Masterkick no ha iniciado sesión   Reply With Quote
Old 10-27-2010, 11:55 AM   #18
kidanger
Pledge
 
Join Date: Aug 2007
Location: France
Posts: 4
kidanger is on a distinguished road
Default

Do we continue Player implementation in the header, or we make a player.cpp file ?
kidanger no ha iniciado sesión   Reply With Quote
Old 10-27-2010, 12:23 PM   #19
Znurre
Marquis
 
Join Date: Jan 2007
Location: RA
Posts: 1,897
Znurre will become famous soon enoughZnurre will become famous soon enough
Default

Quote:
Originally Posted by kidanger View Post
Do we continue Player implementation in the header, or we make a player.cpp file ?
Imo there is no problem using a combined header and source file as long as the class is about as complex as it is now
__________________
Winning a fight is not what makes you a good player, it's how you do it.
http://home.znur.re/screenshot%20201...2011_39_37.jpg
Znurre no ha iniciado sesión   Reply With Quote
Old 10-27-2010, 12:58 PM   #20
kidanger
Pledge
 
Join Date: Aug 2007
Location: France
Posts: 4
kidanger is on a distinguished road
Lightbulb Hotfix + balance update :P

I changed Mob::attack because it needed a pointer :S

main.cpp:
Code:
#include <iostream>

#include "player.hpp"
#include "mob.h"

int main( int argc, char **argv )
{
   std::cout << "Hello Ra !" << std::endl;
   std::cout << "Enter your player name: ";
   
   char name[ 32 ];
   std::cin >> name;
   Player player(name);
   player.punish();
   
   if( !player.isBanned() )
      Mob(player.getLevel() + 5).attack(&player);
      std::cout << player.GetName() << "'s health points: " << player.getHp() << std::endl;
}
player.hpp:
Code:
#ifndef PLAYER_HPP
#define PLAYER_HPP

#include <iostream>
#include <cstdlib> //rand()

class Player
{
   public:
      Player();
      Player(char* n) : banned( false ), level( 1 ), hp( 25 ) { name = n; }
      
      std::string GetName() { return name; }

      void punish()
      {
         std::cout << "<chilko> ban time!" << std::endl;
    
           //TODO
         if(rand()%3 == 2)
         {
            std::cout << "Hacker detected. " << name << " is now banned." << std::endl;
            banned = true;
         }
      }

      unsigned int getLevel()
      {
         return level;
      }
      
      bool isBanned()
      {
         return banned;
      }
   
      void takeDamage(unsigned int damage)
      {
	 hp -= damage;
	 if(hp < 0) // let's keep regnum's bugs :)
	    die();
      }
      
      void die()
      {
	 level -= 1;
	 respawn();
      }
      
      void respawn()
      {
      }
   
      unsigned int getHp() { return hp; }
   private:
      std::string name;
      bool banned;
      unsigned int level;
      unsigned int hp;
};

#endif
mob.h:
Code:
#ifndef __MOB_H
#define __MOB_H
#include "player.hpp" /* Note to author: please separate implementation from headers, no one likes
                      * to compile a module for file that includes its headers */

class Mob {
  public:
    Mob(unsigned int level);
    void attack(Player * player);
};
#endif
mob.cpp:
Code:
#include "mob.h"

#include <iostream>

Mob::Mob(unsigned int level)
{
}

void Mob::attack(Player * player)
{
  std::cout << player->GetName() << " was attacked by a vicious creature!" << std::endl;
  player->takeDamage(15);
}
Have fun !
kidanger no ha iniciado sesión   Reply With Quote
Reply

Tags
programming code game


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
NGD Studios 2002-2024 © All rights reserved