http://code.google.com/p/grails-js-mud/
This project was created as a way for me to explore new technologies while attempting to fulfill my goal to construct a game. Unfortunately, it has not resulted in a game, but more of a collection of proof of concepts. Also, the organization of the code is a disaster. Now that it is public facing it probably should be cleaned up so it doesn't look like a dumpster of code. Anyway here is a review on some of the basics of what exists today.
Player Positioning
This was done using a third party library for STOMP in javascript (http://code.google.com/p/stompj/) and Active MQ which exposes a STOMP/WebSocket transport connector. I went down this road because I have used Active MQ in the past and was very happy with the flexibility it provided down the road (in regards to security / message filtering / routing) and it was also an easy way to setup message broadcasting to multiple subscribers. The player positioning itself is pretty lousy. It sends a direction, position, roomId, and playerId every time the input changes for a single player. If two systems run at different frame rates players end up at different locations for the two systems. The position that is sent will correct this error in positioning when the player changes directions or stops moving. I think I may change this to send absolute position updates instead of using vectors.
See web-app/js/com/unknown/Console.js (use of STOMP)
See web-app/js/com/unknown/GameWindow.js (com.unknown.Entity is the player, inputChanged is a hook for the controller... yeah I know "booo for my code organization / cleanliness / and lack of proper design", remember this was my prototyping spiraling out of control mixed in with a desire to produce something)
Endless World (Technically not endless, but close enough)
This should be in pretty good shape now, essentially each room is rendered as a set of cells and each cell corresponds to a page on the server. When the room loads it requests the contents of each cell from the server using their relative distance from the origin (0,0) of that room. As the player moves in a given direction some cells will no longer be visible, in which case they are re-positioned on the opposite side of the screen and an AJAX call populates the contents of the cell.
See web-app/js/EndlessGrid.js (Logic for managing cells)
See web-app/js/HexGrid.js (A cell described by hex locations)
See web-app/js/init.js (An implementation of the cell loader callback is in there)
See web-app/endlessroom.html (Initial workspace for the proof of concept, not sure if it still works)
Wall/Path Painter
This was the most recent addition. This proof of concept was intended to reduce the effort involved in producing consistent assets for walls / dirt paths and provide logic to easily place them within hex regions. It ended up being a brute force approach to the problem, and the assets aren't 100% but it's entertaining to play with none the less.
See web-app/js/PathBuilding.js
See web-app/js/PathPainter.js
Asset Rendering Scripts
In order for the previous proof of concept to work, assets needed to be marked up with metadata and then processed after they were rendered. The asset rendering scripts will build images from Blender files and Inkscape files and will take different actions depending on the metadata found within those files.
See grails-app/scripts/CropPaths.groovy
See grails-app/scripts/RenderAssets.groovy
See grials-app/scripts/RenderFilmStrip.groovy
See /render.py
See /circle_render.py
Triangle Hit Detection (And therefore Polygon Hit Detection)
Triangles are awesome. Hit detection boils down to the following algorithm. Given a triangle and a point, the point is inside the triangle if and only if the sum of the area of all triangles constructed with the 4 points is equal to the area of the triangle itself. Pretty awesome stuff.
See web-app/js/shapes/Triangle.js
No comments:
Post a Comment