Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
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 3687 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.

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Offline moogie

JGO Knight


Medals: 12
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.
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



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

For changing the stats and knockback:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
--------------Enemy Class---------------------
public void attack(Player p){
p.health = p.health - damage; //damage is an Enemy class variable(integer)
knockBackPlayer(p);
}

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
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
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.

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
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.

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
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.
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (14 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!