f.l.x
|
 |
«
Posted
2005-12-29 14:44:08 » |
|
Here is my 2nd submision to the contest:  In this game, you are a shepherd dog in charge of a flock of sheeps and you have to guide them to the stable door before the time runs while you mantain the wolves away from them. In fact, the game more a prototype than a full game yet, but it's still playable  . I tried to implements some steering behaviors patterns, but i had to cut out many things to fit in  however, there are some bytes left, and is litle optimized, so any feature request / bug report is apreciated. size 3853 bytes. 3 levels. 3825B. unlimited levels. tested on linux and winxp. [size=12pt] play the game (server)[/size]
|
|
|
|
Riven
|
 |
«
Reply #1 - Posted
2005-12-29 15:13:15 » |
|
Nice game! The wolves are no match really, you just hunt 'em down and you're safe. Wolves should be faster than the player, and to compensate they should keep a larger distance from the player. You can save 1 byte by changing "enought" to "enough" 
|
|
|
|
f.l.x
|
 |
«
Reply #2 - Posted
2005-12-29 16:57:08 » |
|
ok, updated now the wolves are quite a challenge, they are imortal, but they will flee you more effectively if you pursuit them, and they can go out of the screen bounds, so they might be there even if you can't see them  added generated levels, not as fun, but it saved some bits.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Malohkan
|
 |
«
Reply #3 - Posted
2005-12-29 17:01:47 » |
|
Very cool game! I got through the first two levels, but the 3rd level I tried multiple times and never even got close hahaha. There was always one wolf I couldn't get near. If I was near one, or maybe 2, the 3rd one was free to play. So essentially I had a constant decrease in sheep and if I dealt with wolves, I was wasting my time and sheep ended up scattered all over the screen. If I tried to herd and minimally scare off wolves, I wasn't fast enough to get the % of sheep I needed by a long shot. Maybe I just stink, but between levels 2 and 3 that's quite a difficult learning curve 
|
|
|
|
appel
|
 |
«
Reply #4 - Posted
2005-12-29 18:03:11 » |
|
Neat game.
|
|
|
|
swpalmer
|
 |
«
Reply #5 - Posted
2005-12-29 18:39:53 » |
|
Yeah, neat!
Though with 400 sheep it really slowed down. I suspect you haven't done anything to try to optimize the number of sheep-to-sheep "attraction" calculations. Not that you have a lot of options with 4k.
|
|
|
|
appel
|
 |
«
Reply #6 - Posted
2005-12-29 20:36:55 » |
|
I ran it on my computer at home and the game is slow like hell, which is weird because my home pc is more powerful than my work pc.
P4 2.6ghz, 1 gig ram ATI 9600xt 256mb ram windows xp
|
|
|
|
f.l.x
|
 |
«
Reply #7 - Posted
2005-12-29 22:25:03 » |
|
i noticed that on some windows boxes, it becomes slow win more than 400 sheeps. In linux ran fine with >750 sheeps i'll trade drawing the actors with something more ellaborated than ovals for some optimization 
|
|
|
|
kappa
|
 |
«
Reply #8 - Posted
2005-12-29 23:19:36 » |
|
great game i enjoyed it alot, as for performance you may want to try 1
| <property name="sun.java2d.noddraw" value="true"/> |
flag, usually helps improve the performance by a little.
|
|
|
|
|
f.l.x
|
 |
«
Reply #9 - Posted
2005-12-29 23:59:27 » |
|
ok, updated the jnlp with the noddraw property and the -server vm argument, see if it makes it playable with >400 sheeps
i'll upload now a easier version (less sheeps required to pass)
|
|
|
|
Games published by our own members! Check 'em out!
|
|
noblemaster
|
 |
«
Reply #10 - Posted
2005-12-30 00:07:31 » |
|
The game requires the "server" JVM, but I only have the "client" installed here (i.e. the JRE only). You might want to change the jnlp to start in client mode. I just get an error message! Cannot run the game. 
|
|
|
|
f.l.x
|
 |
«
Reply #11 - Posted
2005-12-30 00:24:32 » |
|
ok, that was a random shot uploaded another jnlp. However, the one with the -server argument is here
|
|
|
|
kappa
|
 |
«
Reply #12 - Posted
2005-12-30 02:50:48 » |
|
the -server arguement isn't really a good idea to use with games as it won't really give a performance enhancement instead it usually does the opposite for games. since it takes a few minutes for the optimisations to kick in.
|
|
|
|
|
f.l.x
|
 |
«
Reply #13 - Posted
2005-12-30 14:12:24 » |
|
I'm having problems to optimize the sheep to sheep loop due the data structures i chosen to use. the loop looks like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| for(int i = 0; i < sheep.length; i += 4){ if(sheep[i] == -1) continue; desired_vx = desired_vy = avg_x = avg_y = num_on_range = 0; for (int o = 0; o < sheep.length; o += 4) { dist = (float) Point.distance(sheep[o], sheep[o + 1], sheep[i], sheep[i + 1]) + 0.1f; if (dist < SHEEP_VIEW_RANGE && (o != i) && sheep[o] != -1) { num_on_range++; desired_vx -= ((sheep[o] - sheep[i]) / dist); desired_vy -= ((sheep[o + 1] - sheep[i + 1]) / dist); avg_x += sheep[o]; avg_y += sheep[o + 1]; } } [...] } |
I tried to loop only for some sheeps before and after the 'i' sheep, but without ordering the array it doesn't work, and ordering each frame kills the game. I also tried to check if the distance on the x or y was too much but it seems that any checking kills the performance if there are more than 1000 sheeps  any idea
|
|
|
|
swpalmer
|
 |
«
Reply #14 - Posted
2005-12-30 15:37:38 » |
|
Restructuring the data would be necessary to get any big benefit.. though there are some minor opimization that can be done with your existing loop. Computing the distances is one of the more expensive operations. There are ways to speed it up: 1 2
| dist = (float) Point.distance(sheep[o], sheep[o + 1], sheep[i], sheep[i + 1]) + 0.1f; if (dist < SHEEP_VIEW_RANGE && (o != i) && sheep[o] != -1) { |
First check o!=i and sheep - != -1 BEFORE computing the distance.
Instead of using Point.distance do your own computation.. but leave off the sqrt just compute (dx^2 + dy^2). Then compare to squared SHEEP_VIEW_RANGE^2 instead. Then only inside the if block do you need the sqrt, AND you can save the dx & dy values in local vars so they don't need to be recalculated when computing desired_vx & desired_vy.
|
|
|
|
nva225
|
 |
«
Reply #15 - Posted
2005-12-30 18:11:39 » |
|
Hmm nice game, but very ambitous with the (very cool) gravitational pull aspect. The giant "sheep balls" are interesting to watch. Too bad it begins running slowly around 500 sheep, as you're already aware.
Sorry I can't really think of anything else to help out besides what swpalmer already said.
Only thing that crosses my mind, though you're probably already doing this, is to make sure you're not drawing two circles for each sheep, and you're just pasting a pregenerated image where needed. Java circles are pretty slow.
|
|
|
|
|
CaptainJester
|
 |
«
Reply #16 - Posted
2005-12-30 18:34:29 » |
|
Runs fine on my machine. I only made it to the 4th level. 750 sheep I think. Too hard with 3 wolves. Maybe you could have the wolves fight each other a little bit as a distraction for them. Overall well done. Especially like the flocking.
AMD Athlon64 3000+ 512MB Dual channel Radeon 9600PRO
|
|
|
|
nonnus29
Senior Member   
Giving Java a second chance after ludumdare fiasco
|
 |
«
Reply #17 - Posted
2005-12-30 19:33:10 » |
|
I'm having problems to optimize the sheep to sheep loop due the data structures i chosen to use. the loop looks like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| for(int i = 0; i < sheep.length; i += 4){ if(sheep[i] == -1) continue; desired_vx = desired_vy = avg_x = avg_y = num_on_range = 0; for (int o = 0; o < sheep.length; o += 4) { dist = (float) Point.distance(sheep[o], sheep[o + 1], sheep[i], sheep[i + 1]) + 0.1f; if (dist < SHEEP_VIEW_RANGE && (o != i) && sheep[o] != -1) { num_on_range++; desired_vx -= ((sheep[o] - sheep[i]) / dist); desired_vy -= ((sheep[o + 1] - sheep[i + 1]) / dist); avg_x += sheep[o]; avg_y += sheep[o + 1]; } } [...] } |
I tried to loop only for some sheeps before and after the 'i' sheep, but without ordering the array it doesn't work, and ordering each frame kills the game. I also tried to check if the distance on the x or y was too much but it seems that any checking kills the performance if there are more than 1000 sheeps  any idea 1) you don't need to sort the entire array every frame, only about 1x a second I'd guess 2) you could use another array with indexes into the sheep array to implement a quad tree or something like that.... The game is pretty cool as is, do you really need more sheep? 
|
|
|
|
|
DonaldEKnuth
|
 |
«
Reply #18 - Posted
2006-01-02 02:32:42 » |
|
Very nice and fun game! Ran fine on my 2Ghz 512mb RAM Windows XP Pro. box.
|
|
|
|
Anon666
Junior Member  
aka Abuse/AbU5e/TehJumpingJawa
|
 |
«
Reply #19 - Posted
2006-01-02 20:04:37 » |
|
No wonder if is slow, you are performing sheep.length*sheep.length square roots!!! How about you change this line :- 1 2
| dist = (float) Point.distance(sheep[o], sheep[o + 1], sheep[i], sheep[i + 1]) + 0.1f; if (dist < SHEEP_VIEW_RANGE && (o != i) && sheep[o] != -1) { |
into this :- 1 2 3
| dist = (float) Point.distanceSq(sheep[o], sheep[o + 1], sheep[i], sheep[i + 1]); if (dist < (SHEEP_VIEW_RANGE-0.1f)*(SHEEP_VIEW_RANGE-0.1f) && (o != i) && sheep[o] != -1) { dist = Math.sqrt(dist) + 0.1f |
It will remove a considerable number of sqrt's, with only a small size cost. It'd be even better if you can change the desired_vx stuff inside the if, so it can use the square of the distance.
|
|
|
|
|
lyeoh
|
 |
«
Reply #20 - Posted
2006-01-07 15:25:03 » |
|
The game got really slow from level 10 onwards - 2000, 2200 etc sheep! At that point it got pretty easy to save the required 200+ sheep - the wolves just can't kill 1800+ sheep fast enough, in fact the wolves were very helpful when you need to herd bigger bunches of sheep at a faster speed  . Once you have 1500+ sheep you can only herd them in small chunks unless you have have help from the wolves. Nice game though, even though it got slow, I still continued playing  .
|
|
|
|
|
f.l.x
|
 |
«
Reply #21 - Posted
2006-01-07 21:36:18 » |
|
Thanks i'm following some of those tips now, i have been intentionally away from eclipse for this seasons holidays, so there is no changes yet, but there will be. Only thing that crosses my mind, though you're probably already doing this, is to make sure you're not drawing two circles for each sheep, and you're just pasting a pregenerated image where needed. Java circles are pretty slow. in fact i'm drawing the ovals each cicle, it's slower, but it saves me some bytes from image variables and drawing the ovals into them for the first time, but i'll maybe do so, and put something else than ovals for all the actors do you really need more sheep? i'm working in a litle gameplay twist (for the levels to make some sense, and to be a litle more playable) wich implies a limited number of sheeps  anyway implement a tree for the sheeps could be too mucho for the space remaining  i have left that loop like this, for now 1 2 3 4 5
| dist = ((sheep[i] - sheep[o]) * (sheep[i] - sheep[o])); dy = ((sheep[i + 1] - sheep[o + 1]) * (sheep[i + 1] - sheep[o + 1])); if ((dist + dy) < (SHEEP_VIEW_RANGE * SHEEP_VIEW_RANGE)) { num_on_range++; dist = (float) Math.sqrt(dist + dy) + 0.1f; |
thanks alot
|
|
|
|
|