Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to create a simple Enemy class?  (Read 2274 times)

0 Members and 1 Guest are viewing this topic.

Bambo

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to create a simple Enemy class?
« on: September 04, 2011, 01:39:56 pm »
Hey i'm a complete beginner to SFML as you've probably guessed however i've read through most of the tutorial and wanted to create a class which can handle my entity's such as Enemies.

In my enemies class i would like it to be able to update for its logic and draw and stuff but i really can't figure out how it would look. If anyone could help that'd be awesome.

Basicly - How would a class which handles something like an Enemy look like?

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
How to create a simple Enemy class?
« Reply #1 on: September 04, 2011, 01:51:49 pm »
I think you should use more than one class to handle ennemy and it's IA.

An ennemy is an entity like others, it has PV, perhaps energy, etc...
A controller... control an entity. The controller should be inform of events in the Update part of your main loop and make move/attack/whatever your entity.
Note than, if you want complicate things a little bit, a controller can be a keyboard controller, a bot controller, a team controller, etc...

It's my vision, there's perhaps another best solution.

Bambo

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to create a simple Enemy class?
« Reply #2 on: September 04, 2011, 05:16:35 pm »
Thanks for replying.

Let me use a different example.

So i want to make a class which you can do something like Text.Create( "Hello" ) its just an example so ignor the fact that its simple to do anyway.

In the class, how would it be structored? the part which I don't really understand is where you Draw or Update it or whatever.

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
How to create a simple Enemy class?
« Reply #3 on: September 04, 2011, 08:16:54 pm »
Just have an update methos, and a draw method.
each called in their resective areas

 

anything