Jump to content

  • Log In with Google      Sign In   
  • Create Account

Drakonka

Member Since 04 Oct 2012
Offline Last Active Oct 03 2014 08:26 AM

Topics I've Started

Creating a server-side movement/positioning system for a web simulation

13 September 2014 - 12:30 PM

Hi,

 

I'm creating a web based snail simulation using PHP (I know.) with Laravel. I am using HTML5 canvas/JS to render moving snails on jar and snail profile pages. MySQL is used for the db. Each snail has several senses that are determined by its training/treatment and genetics, dictating how well it can smell, see, feel, etc other objects within its jar. So, I need to store x and y positions for each object in the jar (snails, consumables, decoration, etc), which will then be used when each snail's "brain" processes incoming data (does the snail see this object that's a certain distance away? Does it smell the object? Does it perceive it at all with any of the senses? Once an object is perceived I will get stuff like how much attention the snail dedicates to the object, whether it has any short or long term memories of it, etc (basically decide if the snail reacts and how). (This is a very long term hobby project, so I realize that it's overly ambitious and I don't care smile.png)

 

However, I'm not sure how to approach the first step of this - I'm not quite sure what the best way to set snail position is. Currently I set a position within the jar at random whenever a snail hatches from its egg (posX and posY, based in part on jar capacity). From there, when I view the profile page of the jar that snail is in, the snail is spawned in that position. It then chooses a direction to crawl in at random and crawls in that direction based on its currentSpeed attribute. When it hits the edge of the jar it just turns back around. All of this, after getting the first spawn position of the snail, is random and purely client-side JS. Nothing is stored back in the DB just yet.

 

Here's what it looks like (each snail here is is moving toward the edge of the canvas, where it will flip around):

 

ejUcM1Y.png

 

Right now I'm trying to find the best approach to take when making movement that actually persists, and not just random back and forth on the client. Snails move and perform actions even when nobody is watching them, so I know I will need to run a recurring job on the server at regular intervals for this. Things I'm unsure about are:

  1. How to make this scalable to support movement (and then decision-making) calculations for potentially thousands of snails. I guess I should run this job at staggered intervals and not have one giant job for all the snails in the world, but is that really enough to totally mitigate potential performance problems caused by this? I already run recurring jobs for things like snail growth, ageing, and energy depletion. I am fully aware that it's highly unlikely anybody will actually use this simulation or that I'll ever have thousands of (living) snails in the world, but I still want to make it scalable for my peace of mind.
  2. How best to have the HTML5/JS rendered version of the snails on the client see and follow the actions on the server in real time. I guess I'll need to project some sort of targetPosition from server to client and then have the client draw the snail crawling toward that point? Or would it be better to have a target direction? Or maybe do it an entirely different way :S
  3. How best to send some actions from the client back to the server in real time (like dragging an item or snail while in jar-view, thereby repositioning that object in the db). 

I suppose I'll have to use something like Ratchet (or in this case maybe Latchet), but I'm in general looking for any examples or high level advice on how to approach this sort of thing best - the actual implementation I can then sort out on my own. I just want to have a solid plan for how to structure this before I dig in and could use some advice/starting point suggestions for how a system like this should work.

 

Thanks in advance for any advice/suggestions!


Advice for managing two different codebases for one game using Git (browser and iOS ver...

11 October 2012 - 04:37 AM

I'm making a JavaScript and HTML5 game. I mostly work in the browser on my Mac, but the final ideal goal is to deploy on iOS as well as browser. Therefore at least a couple of times a week I compile the entire thing using a different framework to deploy to and test on my iPhone. Most of the code ports over nicely, but as you can probably expect some parts require modifications and tweaking (not to mention the fact that the browser version does not need the framework files). This results in my having to change up various piece of code in both files on the day that I test the port. I try to consolidate the code as much as possible and sometimes end up making edits to the iOS code that are ported back to the browser code, or vice versa. Juggling two codebases for the same game can get quite confusing and a hassle in general.

The editing timeline basically looks like this:
  • Work on browser version, add new features, test, etc. Doing this in the browser allows me to work much more efficiently than compiling and testing in Xcode each time.
  • End of week port entire thing to iOS framework, deploy to iPhone
  • That day fix any problems in iOS port, try to consolidate code between the two as much as possible. This results in tweaks being done in both codebases and copies/pasted between each other that day
  • Continue working on browser version until next port
Right now I use Git for version control, hosting my code on Github for the browser version of the game. I have a dev and master branch. I do not currently use version control for the iOS version at all because I do not know the best way to set this thing up. Should I maintain the entire iOS codebase including the framework in another branch of my main game repo? Should the iOS version be in its own repo? Ideally I'd be able to set it up so that I can just pull relevant files from the browser branch to the iOS branch when I'm testing the port (but sometimes parts of the code would need to be left out, as there are some differences required), then push necessary changes back to both the browser and iOS versions of my hosted code.

I'm not a Git expert and am just not sure what the best way is to go about this. Right now I mostly use it for keeping a main working version of the game in one branch and merging the development branch into it when experimental stuff gets finalised. Fiddling with two sets of code on these porting days is getting confusing and I'm finding myself making mistakes, plus wasting tons of time. Can anyone advise how one might manage this kind of thing better?

Opinions on resetting difficulty+experiencing the same series of overarching events fro...

11 October 2012 - 01:48 AM

I'm curious about people's views on having the player (optionally) experience the same story from three different perspectives in different playthroughs. I was originally going to post this in the Writing forum, but realized the question is more about the overall player experience in terms of progression rather than the story itself. Apologies if I was wrong and placed this in the wrong forum.

The idea: The core mechanics basically involve an Asteroids-like multi-directional shooter and build on that. The player selects a character they want to play out of three at the beginning (female, male, AI) based on a brief description and an overview of strengths/weaknesses. Player completes playthrough with that character, then optionally chooses another character to use and starts from the beginning of the overall story timeline. I'm guessing each character's playthrough may take 45 minutes to an hour (but this estimate is still very flexible).

Progress: Most of the core mechanics are complete (with much refinement to go), but in terms of content right now I am building levels for the first character, allowing me plenty of opportunity to vary up what I'm going to do with the other two based on feedback I receive here.

Question: As a player, would you prefer to experience the same series of events through another character's eyes/personal perspective or would you prefer to just have each character progress you further in the main story of the game without overlap? Do you see the former working? As an example:

Character A: Starts at Level 1, Day 1.
Level 1: Recover Blue Widget from planet.
Level 2, 3, etc
Finish playthrough


Character B: Starts back at Level 1, Day 1.
Level 1: Defend main ship from attack for X time while Blue Widget is being recovered from planet.
Leve 2, 3, etc.
Finish Playthrough


versus

Character A: Starts at Level 1, Day 1, finish at Level 10, Day 10
Character B: Starts at Level 11, Day 11, continuing where A left off.

The first case would be a matter of optionally restarting from the lowest difficulty after you are done with whatever character you chose to play first.

The second case would be a matter of continuing the difficulty progression with each character. You would have no choice in what character you use - you'd start with A, go on to B, finish with C. I guess technically here you don't even have to have multiple characters with this option, so the main question is - do you see the first case working to deliver a positive player experience?

Original Rationale: I had hoped that if I can do this right, I can potentially have the player glean new pieces of understanding or information as they experience what's happening from varying points of view. Seeing things from different perspectives is interesting to me personally, and trying to intertwine three paths in that way successfully is even more so. However, I'm not sure if this is actually as potentially fun and interesting as I'm hoping it could be, or if this would give the player the most enjoyable experience even if I manage to do it right in terms of writing this thing. Which is why I'm here, looking for opinions Posted Image

PARTNERS