Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (736)
Games in Android Showcase (223)
games submitted by our members
Games in WIP (813)
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  
  2D Combat System?  (Read 2206 times)
0 Members and 1 Guest are viewing this topic.
Offline ral0r2

Junior Devvie


Medals: 1



« Posted 2017-07-09 09:14:33 »

Hey guys, I'm currently / still developing a 2D kind of rpg game, inspired by games like Zelda:  The Minish Cap and similiars. I already implemented a battle system, which for me means the player was able to attack enemies with a sword hit, cast spells and get attacked by enemies. However the whole thing ended up in quite a mess and wasn't really robust, maintainable or extandable. I was thinking about that it might be easier or better for my game to implement a combat system in games like Diablo instead.

Does anyone have any recommendations what implementation wise is easier to realize? Furthermore can you recommened any articles about how a good combat system works in detail (regardless of being Diablo style or "realtime" style like zelda)? Something I might get a little bit inspiration from?

Thanks in advance.
Offline orangepascal
« Reply #1 - Posted 2017-07-10 14:33:06 »

pretty vague and extremely open question..

for my latest game the player has an int called myWeaponID, which has the name of the weapon, and when player pushes the attack button, it checkes which bullets to spawn based on the myWeaponID.  So the shotgun spawns 3-4 shotgun-bullet types with a random pattern,  and the machinegun spawns 1 machinegun-bullet type but has a higher spawn frequency for faster shooting.

that's probably an answer to your question!

the guy behind Orangepixel | twitter@orangepascal
http://www.orangepixel.net
Offline ral0r2

Junior Devvie


Medals: 1



« Reply #2 - Posted 2017-07-10 14:48:12 »

Thanks for the reply, yeah I kept the question quite unspecific to generate a lot of input, hopefully Cheesy
Did you use object pooling for all of your bullet types?

How would you realize that with a melee weapon? Similiar?
That would be my guess:

1. Check Weapon ID,
2. Spawn collision rectangle according to weapon ID in hit direction,
3. Let the collision rectangle disappear after a certain amount of time (when the hit is done)
4. Apply hit, or don't
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline orangepascal
« Reply #3 - Posted 2017-07-10 18:50:05 »

well yeah, my melee weapons usually generate an invisible bullet of a smaller size and no movement.

Bullets are an array of a bulletEntity class, and I re-use the "died"  objects. So there's no memory garbage-collection going on. (I also do this for all other entity objects)

the guy behind Orangepixel | twitter@orangepascal
http://www.orangepixel.net
Offline FabulousFellini
« Reply #4 - Posted 2017-07-10 20:10:19 »

well yeah, my melee weapons usually generate an invisible bullet of a smaller size and no movement.

Bullets are an array of a bulletEntity class, and I re-use the "died"  objects. So there's no memory garbage-collection going on. (I also do this for all other entity objects)

Thanks, that's a really cool idea.  I just figured you had a hit box for the sword or something but the bullet thing makes a lot more sense.

-FabulousFellini
www.fabulousfellini.com
Offline tariqbroadnax

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #5 - Posted 2017-07-12 17:17:19 »

You probably do not want melee attacks to work like range attacks because melee attacks usually must move with the user. That is, their position is relative to the user whereas range attacks exist by themselves. Think: punching someone vs throwing a shoe at them. You do not have to do it this way but it is just something to keep in mind.

Also, combat systems are only as complicated as you make them. In my opinion, at their highest levels, they are all just chunks of code, abilities or attacks, that can be started, stopped/ended, and updated. Even things like weapons fit into this pattern. That hardest part is creating a interface that your engine can call easily. The actual logic part is usually very simple, albeit debugging is always a hassle.
Offline ral0r2

Junior Devvie


Medals: 1



« Reply #6 - Posted 2017-07-14 07:46:33 »

You probably do not want melee attacks to work like range attacks because melee attacks usually must move with the user. That is, their position is relative to the user whereas range attacks exist by themselves. Think: punching someone vs throwing a shoe at them. You do not have to do it this way but it is just something to keep in mind.

Also, combat systems are only as complicated as you make them. In my opinion, at their highest levels, they are all just chunks of code, abilities or attacks, that can be started, stopped/ended, and updated. Even things like weapons fit into this pattern. That hardest part is creating a interface that your engine can call easily. The actual logic part is usually very simple, albeit debugging is always a hassle.

Thanks for the input, I definitly see your point. What about a combat system like the one of Diablo? For example I rightclick an enemy and my character starts auto attacking the target, are hitboxes usually required there? Or is it rather like if the distance to the target is close enough simply go into a battle states and attack each xxx seconds?
Offline Glabay
« Reply #7 - Posted 2017-07-14 11:31:10 »

idk if this will help any or not.

I am working on my Combat System in a 2D Top Down RPG, I wrote a Cache system to hold the sprites and some info.

as an example when I add new items into my game I do so through this tool, I give the items their bonuses and required levels and skills to equip the item in question. I also added an option to know if the items is a weapon, if it is I have to give it an "attackSpeed" byte I am using 1-5   1 being the slowest 3 is "normal" and 5 is Fastest.


So when I go to begin Combat before each "attack" I check the equipped items and get the attackSpeed based on the equipped item ID

I am doing it this way so you can switch your equipment on the fly in combat, I don't have a class system, you are what you equip.

PI * 13.37 = 42
There are 10 kinds of people; those who know Binary and those who don't
Why programmers confuse Christmas and Halloween; Because 31 OCT = 25 DEC.
Offline tariqbroadnax

Junior Devvie


Medals: 2
Exp: 3 years



« Reply #8 - Posted 2017-07-15 18:40:07 »

@ral0r2

Yeah, the second thing you said.
Offline ral0r2

Junior Devvie


Medals: 1



« Reply #9 - Posted 2017-07-17 12:17:29 »

Thanks guys, your input really brought some light into the darkness for me Smiley !
Pages: [1]
  ignore  |  Print  
 
 

 
cybrmynd (120 views)
2017-08-02 12:28:51

cybrmynd (144 views)
2017-08-02 12:19:43

cybrmynd (139 views)
2017-08-02 12:18:09

Sralse (154 views)
2017-07-25 17:13:48

Archive (624 views)
2017-04-27 17:45:51

buddyBro (733 views)
2017-04-05 03:38:00

CopyableCougar4 (1260 views)
2017-03-24 15:39:42

theagentd (1239 views)
2017-03-24 15:32:08

Rule (1216 views)
2017-03-19 12:43:22

Rule (1268 views)
2017-03-19 12:42:17
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!