Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411574 Posts in 69386 Topics- by 58444 Members - Latest Member: darkcitien

May 04, 2024, 06:10:23 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsJombies - experimenting with JavaScript Multiplayer
Pages: [1]
Print
Author Topic: Jombies - experimenting with JavaScript Multiplayer  (Read 2239 times)
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« on: September 08, 2010, 02:08:23 PM »

 * Video, 10. September - two green soldiers protecting sheep

----------

What I really always wanted to do it Multiplayer games. I tried in Java & Python but.. it's really hard (it's not getting easier.. but..).

I've been working a lot with JavaScript lately. And in the browser, when you are already connected to the Web! - it should be easier to get something going.

After several failed attempts I think with the new Websockets (works in older browsers via flash fallback) doing multiplayer games with a simple message passing server & all clientside code might actually be feasable - at least for prototyping or slow games (e.g, turn based).

And who wouldn't want to proto a multiplayer match Smiley



So i give you 5h of work. A WebSocket Multiplayer Shooter - my puny server will probably die if more than.. I don't know.. 5?... will join.

What 5h?
---------
Well I already had the basic Graphics and Input code from a bigger project on which I didn't want to work on today.

So how do I try it?
--------------------
It runs on my server, not the fastest and the game will download 3 MB of pics from a german server without a loading bar - so be patient.

I'm not sure this works in IE, it might. FF & Chrome & Opera are fine. Chrome is best.

http://nekapuzer.at:8080/ (currently offline)

Controls
--------
  * ARROW Keys or KEYPAD to walk around
  * SPACE shoot
  * ENTER throw grenade (not really implemented i think.. lol)
  
It's coop! Kill all Zombies - though they are harmless until I write the biting code.

Phew.. now I gotta sleep  Yawn Have fun

 - OS
« Last Edit: October 15, 2010, 03:24:14 AM by oberhamsi » Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #1 on: September 09, 2010, 07:18:03 AM »

Okay this is progressing nicely Smiley

I now have the following working in multiplayer:

  * shooting - blood spatter if you hit a zombie
  * grenade throwing - instant kill zombies in blast radius
  * zombies bite you if they get too close
  * zombies & soldiers currently both have 10 hitpoints



Turning it into a Game
------------------------

It's fun already but without a goal this is just an engine test. So to make it a playtestable, coop game I need a goal for the players!

Maybe the players should have something to protect - a moving character perhaps. I might, for example, have a random Spawn position (visualized as a house) where Docs come out and they have to get somewhere. And the players get a scorepoint for every Doc that makes it there alive.

That should be doable.

Other Todos
------------

Once it does have a goal I want to...

  * add at least one more enemy type - maybe one that doesn't move in a straight line. Probably something small & fast (spider?)
  * limit amount of grenades the players have
  * make a lobby and make server capable of hosting multiple games
  * display scores
  * display healthbar on player's soldiers

Once I managed all that I'll setup a bigger server so at least a couple dozens people can play concurrently.
« Last Edit: October 15, 2010, 03:24:25 AM by oberhamsi » Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #2 on: September 09, 2010, 07:19:07 AM »

UPDATE: short screencast http://gamejs.nekapuzer.at/videos/jombies_01.ogv

i should redo with multiple players. just imagine more soldiers running around Wink


Addendum: Client / Server Technicalities
-------------------------------

I'm gonna tell you something about the strange network setup this game has. The server is very stupid. It doesn't keep track of the game state, besides the list of players currently playing. Other then that the server only forwards the messages it gets from one player to all the others.

Every client does the hit calculations for his own players as well as randomly spawn a zombie (if the number of zombies is smaller then 10 * players).

The benefit of all this is that I can very easily add new game logic - I only have to touch the clients, the server will blindely forward the events that new logic generates.

From a security perspective it's terrible but for prototyping it's awesome.

« Last Edit: September 09, 2010, 07:37:54 AM by oberhamsi » Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #3 on: September 10, 2010, 12:22:13 PM »

I mostly did refactoring tonight but was able to squeeze out a couple of easy features in the progress. And I got a goal and a theme. The goal is there and you can pretend you're trying to do good but no one will judge you (aka no scoring).

Highlevel Goal
-----------------
You and your buddy are literally shephards protecting the sheeps being beamed down to a zombie infested planet for feeding. The sheeps are slowly wandering to one of the grass piles, take a couple of bites and stroll back to a teleporter station.

You have unlimited MG ammo, 100 hitpoints and 3 Grenades (big blast).

Grenade crates are placed in inconvinient spots for restocking.


In the Video: soldiers (green guys) = players. See how the sheeps are going to feeding, we somewhat try to protect them - one player is a lot better than the other Wink


New Enemy: Spiders
------------------
Spiders shoot spidernets at you. They walk zig-zag (it looks smarter then it is). They'll get a weak melee attack too.

Enemy: Zombie
---------------
Holds on to you and eats you. No ranged attack.

What is missing (gameplay wise)
--------------------------------
 * make it a restartable match: ~ 10 sheeps being beamed down
 * no unlimited grenades
 * scorekeeping (x points per sheep fed)
 * endgame statistic (kills per enemy type, shots fired, etc)
 * fog effect at borders (so enemies don't just pop in)
« Last Edit: October 15, 2010, 03:25:02 AM by oberhamsi » Logged
OneMoreGo
Level 3
***

Stop looking at my chest


View Profile
« Reply #4 on: September 11, 2010, 07:22:22 AM »

Looks pretty good. Adding something above ground level like a large rock or tree or something that the players can walk in front of or behind might help the feeling of immersion.
Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #5 on: September 11, 2010, 07:58:18 AM »

Looks pretty good. Adding something above ground level like a large rock or tree or something that the players can walk in front of or behind might help the feeling of immersion.

that would probably be the minimum thing to make it feel not flat, you're right. i tried to avoid that b/c i don't have collision detection and only 2 more days but something like a tree should work with a bit of tweaking.

Regarding Visuals..
----------------------
i didn't yet think much about that. I think I'll at least do some kind of fog on the borders of the playing field so enemies don't
just pop up. Other then that a teleporter animation for the sheep is already in the game assets and i just need to activate it.

i've been throwing around crazy ideas like making the players follow the light-beam of the in orbit (invisible) spaceship and around that light beam it's pitch black except for a small headlight the players have... but i think that won't happen until jombies 2.

Mechanic: Kick Back Zombies
----------------------
I think I'll have to implement that. I want shooting / fighting to be real smooth & fun. That's the whole point of the game. Shooting at close is weird with only 8 directions to rotate. some kind of fist kickback attack is in order.

... more news & video hopefully on tuesday Smiley
Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #6 on: September 15, 2010, 08:21:34 AM »

I was fighting with a bad memory leak - strangely only in chrome, the others free'ed it on their own soon enough to not cause a crash.

So that took most of the time. I'm getting behind of schedule so I decided not to add any more features but concentrate on the two essential things missing:

  * scoring
  * multiple games per server

.. my motivation won't get me further. I want something out that can be played without guidance for feedback. Then I'll think about more features (the limited grenades, trees, ...).
Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #7 on: September 23, 2010, 03:58:18 AM »

I won't finish this one. It's playable, i implemented multiple games per server and the whole lobby stuff but it would need further polish to be really enjoable.

It helped me evolve GameJs so it's not all bad.

The major issue I should have seen coming earlier:

  * loading sprites as single images is terrible; 1600+ HTTP Requests just to get the game started up. I need a sprite-packer.
Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #8 on: October 13, 2010, 01:07:54 PM »




danger: code heavy, self lib pimpin' post ahead Wink

I had hit a road block those couple of weeks ago. I didn't exactly know how I wanted networking to look like. I haven't thought about the serverside of the game too much. As I mentioned, I only did a simple multiplexing of all the messages without serverside processing - enduring all the insecurity & limited possibilities that brings.

I solved it and progress has happened. I improved my tool, GameJs, which I'm extracting from this bigger game and all the small example games. All but Jombies already work with what I added. GameJs has grown network support, which does simple match making & game instantiations. I like it, its simple and takes a lot of my hand. This is how it looks on the client:

Code:
var nc = new NetworkController();
nc.queryGames();
...
nc.joinGame(4);
...
gamejs.event.get().forEach(function(event) {
   if (event.type === gamejs.event.NET_SERVER_HELLO) {
      print (event.player.id);
   } else if (event.type === gamejs.event.KEY_UP) {
      ...
   }
});

The server component of any GameJs game is also written in JavaScript. Maybe more on that another time Wink Let's just say it can do more now then just multiplex.

I think this all starts to fit together nicely, so I wanted to share this short side-by-side with pygame, after which most of it (not the network part) is modeled:




Now it's two weeks holidays and then back to getting Jombies out the door - the last 10%. No release date yet. Stay tuned Smiley
Logged
simono
Level 1
*

screen.blit(fun)


View Profile WWW
« Reply #9 on: October 13, 2010, 01:09:36 PM »

I won't finish this one. It's playable, i implemented multiple games per server and the whole lobby stuff but it would need further polish to be really enjoable.

disregard that. it was shitty.

Quote
The major issue I should have seen coming earlier:

  * loading sprites as single images is terrible; 1600+ HTTP Requests just to get the game started up. I need a sprite-packer.

solved with spritemaps for ISO animation sprites.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic