Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Battle Engine design.  (Read 4175 times)
0 Members and 1 Guest are viewing this topic.
Offline SkyAphid
« Posted 2012-03-11 21:39:03 »

So, it's turn based. The enemy will slide to the player, attack, and he will be knocked back and health will be shaved. Problem is, I don't know how to go about it. The engine has a stats class, a player class, and the enemy classes. Right now, they will slide to the player when it's their turn, but I don't know if I should make an object that collides with the player and triggers the knock back and stat editing, or what. I also considered editing his stats directly from the enemy, and turning a boolean on in the player object to knock back, but then again, that's sketchy too.

All entities are managed by a list in another class called EntityManager.

Any advice would be fantastic.

it just werks
Offline moogie

JGO Ninja

Medals: 16
Projects: 6
Exp: 10 years

Java games rock!

« Reply #1 - Posted 2012-03-11 21:53:10 »

It really is your call.

The direct manipulation from the enemy would be easiest, however the object-event  based method is more extensible.

I would suggest doing the easiest way first for the following reasons:

1. To keep momentum / motivation.... dont underestimate this for hobby game development
2. This is a game, that most likely you are not collaboratively programming so you dont have to have the best / well understood solution to help others understand
3. Normally the easiest/ simplest method is good enough

however if you start to feel restricted by the direct manipulation then you can probably reconsider at that point.

Java4k RIP 2014
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 162
Projects: 5
Exp: 3 years

« Reply #2 - Posted 2012-03-13 02:48:30 »

For changing the stats and knockback:

--------------Enemy Class---------------------
public void attack(Player p){ = - damage; //damage is an Enemy class variable(integer)

public void knockBackPlayer(Player p){
int deltaX = x - p.x; //class variable x and player variable x
int deltaY = y - p.y; //same as above but w/y
//do stuff w/deltaX and deltaY to animate knocking back


If you have only one player character/sprite, then the attack and knockbackplayer methods probably don't need a parameter.
This is just a rough template, do whatever you want with it to fit your needs.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lesto

Senior Newbie

« Reply #3 - Posted 2012-03-13 23:11:03 »

bad idea the knockback done this way. just apply a force on the body, that way you don't break physics and different mass can respond in different way
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 162
Projects: 5
Exp: 3 years

« Reply #4 - Posted 2012-03-14 03:36:46 »

right, it's an engine. forgot about that. thx lesto.
Offline SkyAphid
« Reply #5 - Posted 2012-03-15 01:59:47 »

There is no real physics, it's really just an aesthetic. So he just slides back, since every "Living Entity" in my game has a simple directional movement base in it's parent class. I just set the waypoint 5 units behind where he is, and he slides there with the sprite set up.

it just werks
Offline SkyAphid
« Reply #6 - Posted 2012-03-18 04:19:33 »

Sorry to necro, but I didn't feel it neccesary to make another post for what I'm about to ask.

I can't for the life of me get a smooth fighting engine going, it's just...jumpy. Can I have some design advice please? Thank you.

it just werks
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 162
Projects: 5
Exp: 3 years

« Reply #7 - Posted 2012-03-19 00:30:10 »

Jumpy? Is it a lag problem or algorithm problem? For algorithm problems I would look into excessive use of the EDT thread.
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 162
Projects: 5
Exp: 3 years

« Reply #8 - Posted 2012-03-19 00:39:31 »

And also you should post some code.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Coldstream24 (16 views)
2015-09-03 00:41:28

Andrew_3ds (25 views)
2015-09-01 19:08:10

afikri (17 views)
2015-08-31 09:30:22

afikri (24 views)
2015-08-31 09:30:07

afikri (13 views)
2015-08-31 09:27:24

afikri (16 views)
2015-08-31 09:26:40

Roquen (30 views)
2015-08-29 11:30:54

GamerC4 (36 views)
2015-08-22 20:38:50

GamerC4 (33 views)
2015-08-22 20:37:18

GamerC4 (40 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!