Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
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  
  Spell effects: (Damage-Over-Time) Threading?  (Read 5160 times)
0 Members and 1 Guest are viewing this topic.
Offline Oryan

Junior Newbie

Java games rock!

« Posted 2005-11-22 21:06:51 »

Im designing the spells in my rpg... nukes are easy... heals are easy... but spells that change or affect the player over time are a different ball game.

My Question:

> Should i make each buff that is in my buff list implement Runnable?when they run they proceed to affect the target over time.

> I imagine this can be very taxing on the server. Is this a good way to handle it? or is there a better way?


Offline hvor2

Junior Devvie

Beyond mind, there is an awareness...

« Reply #1 - Posted 2005-11-22 23:04:21 »

If I understand this correctly...
Why don't you add some Vector() on your player object that will contain all active spells. Then, all spell knows when it is "triggered". Every frame you just check "is it time for spell to affect player?".
Yes ---> affect, move trigger time to next trigger time
No ---> go on...

Offline arne

Senior Devvie

money is the worst drug- we should not let it rule

« Reply #2 - Posted 2005-11-23 15:01:52 »

I believe java is very optimised for multi-threading.

:: JOODE :: Xith3d :: OdeJava ::
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline K.I.L.E.R

Senior Devvie

Java games rock!

« Reply #3 - Posted 2005-11-23 15:20:25 »

Why not create a thread specifically for spell effects that works globally?
It's better if you're trying to go for dual core efficiency optimisations.

Is there a name for a "redneck" programmer?

Unemployed. Wink
Offline ryanm

Senior Devvie

Projects: 1
Exp: 15 years

Used to be bleb

« Reply #4 - Posted 2005-11-23 15:54:00 »

IMO, threading in this situation would be a needless complication.

Disregarding the multiple processor case, threading should be used:
  • To keep GUIs responsive when doing processing in the background
  • When faced with blocking I/O operations

I say go with hvor2's suggestion: Have a list of active spells for each player, and check them each frame.
Offline rolz

Junior Devvie

Chief Technopolitan

« Reply #5 - Posted 2005-11-23 16:47:57 »

I'd suggest processing delayed/repeating events in the same thread which processes game events.
But you still can use java.util.Timer (one timer per all delayed effects) if the game engine works fine with multiple threads. Why not ?

Offline ryanm

Senior Devvie

Projects: 1
Exp: 15 years

Used to be bleb

« Reply #6 - Posted 2005-11-23 17:38:01 »

if the game engine works fine with multiple threads. Why not ?

Thread scheduling is dependant on the underlying system, so what works on your development box may not work anywhere else. Also, bugs introduced by multithreading can be right bugger to find and fix, due to this inherent unpredictability.

IMO, threading should be avoided except where you absolutely have to use it, like in the cases above, or when you are completely sure about what you're doing, and there is zero doubt of the benefits.
Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #7 - Posted 2005-12-06 03:08:48 »

Never use threads for this kind of thing. You cannot predict how much time a thread will waste after each sleep or yield. If you want to change stuff in the game from the thread, those things must be synchronized or you will undoubtedly introduce subtle bugs that show randomly, ruining the game. You should either poll each time-dependent thing each frame, or implement a sort of queue which manages them by sorting them at insertion time, then polling the foremost entry for when it should be executed (this is more efficient if lots of stuff is going on).
Pages: [1]
  ignore  |  Print  

hadezbladez (329 views)
2018-11-16 13:46:03

hadezbladez (168 views)
2018-11-16 13:41:33

hadezbladez (327 views)
2018-11-16 13:35:35

hadezbladez (77 views)
2018-11-16 13:32:03

EgonOlsen (2159 views)
2018-06-10 19:43:48

EgonOlsen (2194 views)
2018-06-10 19:43:44

EgonOlsen (1371 views)
2018-06-10 19:43:20

DesertCoockie (1989 views)
2018-05-13 18:23:11

nelsongames (1640 views)
2018-04-24 18:15:36

nelsongames (2289 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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!