Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Web Browser Engine  (Read 5054 times)

0 Members and 1 Guest are viewing this topic.
Web Browser Engine
« on: June 28, 2011, 12:01:27 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
Howdy guys.

I've been running a bit of an experiment lately with the new HTML5 Canvas element. It started as a simple "move up down left right and stop at blocks" thing, but it's grown into a bit of a beast. I'm a massive fan of zelda games so of course this thing has grown into a 2d zelda engine of sorts. As of now it only works in webkit browsers (chrome, safari, etc). Something isn't working in firefox and internet explorer will probably never work. Nevertheless I think it's pretty damn cool to run an engine like this in a browser.

I decided to go about it by programming tiles based on behaviours and then adding on graphic after that. Right now I'm using a debug drawing mode to display the behaviours of the tiles. I've not actually got around to adding in any background graphics yet, but the Link sprites from LTTP are in there and working as intended.

It's a pretty robust collision engine I've got going here actually. The gridsize can be any number of pixels in size and the "your man" boundaries can be any size, and you can go at any set speed.

The collision tiles I've programmed in currently are: walkable, non-walkable, diagonal top left, diagonal top right, diagonal bottom left, diagonal bottom right. The sub-attributes of the tiles are, ladder (half speed), ice (slippery), shallow water (sprite change), deep water (swimming).

There's a z-index for tiles, so we're on a specific 'floor'. The further down the floor the darker the tile appears at the moment. You can jump from calculated ledge locations based on the tiles and z-index of your location in relation to possible jump locations.

There's bridges, so locations that appear over other walkable areas. They can have any collision of attribute as a regular tile, they're indicated by a green border or general green colour. These are controlled by designated bridge entrance' tiles, so you can only activate the bridge layer when entering on a bridge entrance tile. You can also jump down from bridges when there's walkable tiles of a lower z-index at the edge of the bridge.

The basics of the engine in terms of drawing and displaying and whatnot is pretty standard. I'm drawing a set of 'layers' which are independent canvas layers the size of the total area. Background, landscape, bridge, sprite, over. Then applying each layer to a main canvas element the size of the display area with a negative offset. This moves and re-arranges the pre-drawn layers based on position and animation sequences and only has to redraw when the area is initially loaded.

Anyway, here it is. There's just a small test area set up for now, but there's basically just a giant array that could have any combination of tile behaviours in it. Adding graphics will be a simple matter of adding in a sub-value of the X+Y position in the array with a graphic tile reference, then switching from the drawLandscapeBehaviour method to the drawLandscapeGraphics method.

Keys that do stuff at the moment:
Up, Down, Left, Right, X (Dashing)

I'm obsessively working on this thing right now so there will probably be updates to it a lot.
Logged
Re: Web Browser Engine
« Reply #1 on: June 28, 2011, 05:15:14 pm »
  • *
  • Reputation: +10/-0
  • Offline Offline
  • Gender: Female
  • Posts: 1469
A very impressive piece of work I must say, works flawlessly on chrome linux dev. The jumping from cliff faces is most impressive, as is the water engine (walking and swimming). In some ways it is more complete than engines people write for full games designed to run natively on a machine.

This is a very interesting project and I would love to see it progress.
Logged
  • Elliott Parkinson
Re: Web Browser Engine
« Reply #2 on: June 28, 2011, 07:11:50 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Yeah, the HTML5 canvas element is opening a lot in the way of game development. I ported a simple Jumper tutorial from Javascript to CoffeeScript, using a canvas as the viewport. To be honest, though, I still prefer other RIA systems for their power and speed, as a lot of browsers like to slack on their Javascript performance (or as my browser of choice, Opera, does - get uber strict with their script parsing and execution).

Pretty nice to see how much you've been able to do with it so far, though.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: Web Browser Engine
« Reply #3 on: June 29, 2011, 04:26:49 am »
  • It's just Max.
  • *
  • Reputation: +18/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1355
This is way cool, man. I don't know much about coding and stuff, but I think putting the higher levels a lighter shade was brilliant, you can just use one colour and the z-axis will shade the graphics for you according to height. I mean, that probably won't be as important when the graphics have advanced beyond yellow and white blocks, but still, very clever. What exactly are you planning to do with this, if I may ask?
Logged
Re: Web Browser Engine
« Reply #4 on: June 29, 2011, 08:36:26 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
This is way cool, man. I don't know much about coding and stuff, but I think putting the higher levels a lighter shade was brilliant, you can just use one colour and the z-axis will shade the graphics for you according to height. I mean, that probably won't be as important when the graphics have advanced beyond yellow and white blocks, but still, very clever. What exactly are you planning to do with this, if I may ask?

The colouring is intended for debuging initially (like, figuring out the exact behaviour of a block including height relative to other tiles without having to look at a big dirty pile of numbers to figure out a problem). I like your thinking though, since it's just a block of black over the pre-drawn tile with a set transparency value there's nothing stopping it shading graphics too. That could be cool.
E:
I'm not sure what to do with it at the moment. I can conceive in my mind of a full online interface for game building, but that's a pretty serious piece of kit and I'm not sure I have the commitment for it. There's also an experiment I want to run using DICKBUTT and session ID's for real-time netplay. I can't see it having good latency though. Maybe some sort of turn based thing would work, I don't know. It's still just a crazy experiment for now.


To be honest, though, I still prefer other RIA systems for their power and speed, as a lot of browsers like to slack on their Javascript performance (or as my browser of choice, Opera, does - get uber strict with their script parsing and execution).

I know exactly what you mean. I'm hoping it won't be the case, but I'm expecting once there's enemies, objects, interactions, events and so forth added in there there's going to be some lag at points. I've set it up to run at a steady 30fps but if it lags behind that with the calculations it'll slow down. I'm doing my best to set it up so that it can pre-calculate and cache as much as possible, but there's only so much that can be pre-calculated. I'm pretty optimistic about it though since there's some serious browser competition over JS performance at the moment and there's been great strides in the last year or so. Plus, worst case scenario it would just need small areas. With proper transitioning that's not a big issue.

A very impressive piece of work I must say, works flawlessly on chrome linux dev. The jumping from cliff faces is most impressive, as is the water engine (walking and swimming). In some ways it is more complete than engines people write for full games designed to run natively on a machine.

I love how the water works, it's really really easy. Ice physics and a sprite change. :D
The cliff faces were pretty complicated to work with. It started out with a non-walkable tile property of 'jumpable'. Then counting the frames 'pushing' against it. Instead I installed the z-index and now it detects a non-walkable wall with a lower z-index and counts the frames. Once it reaches 20 frames it triggers a checking algorithm. It calculates the amount of walkable tiles needed for your mans boundaries to land on and then goes down each row checking the calculated projected landing co-ordinates for a free spot. If it reaches the end of the map and nothing is found the jump is canceled, if it finds a spot it triggers the jump animation sequence with the distance parameter. This might need changing later for tiles that change from walkable to non-walkable in real time.
« Last Edit: June 29, 2011, 08:40:43 am by DeadMint »
Logged
Re: Web Browser Engine
« Reply #5 on: June 29, 2011, 11:18:27 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3374
Not working in firefox 5.0? It loads but my keys do nothing.
Logged
Quote from: Jason
Your community is a bunch of stuck up turds.
Re: Web Browser Engine
« Reply #6 on: June 29, 2011, 11:26:55 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
Currently it only works in webkit browsers (and maybe opera, I don't have it installed right now and the opera site is giving me an error when i try to download it). Chrome and safari are the two main ones. I'm working on the issues in the gecko JS engine and I should be able to get it working for FF5. Don't hold your breath for IE though.
Logged
Re: Web Browser Engine
« Reply #7 on: June 29, 2011, 02:31:53 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
No, keys don't work in Opera. :p
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: Web Browser Engine
« Reply #8 on: July 08, 2011, 10:26:02 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
Version 0.25

Changes:
Fixed bug when stopping dashing that stopped all movement
Rewrote input detection
Added support for Firefox 5 and Opera

Hooray, cross browser support. Pretty important for a browser game I'd say. I took a crack at making it work in IE just for laughs, I crashed it in about fifteen different ways at once, it was beautiful.

By the way, the flower and rock don't do anything yet. I decided to play around with a landscape editor before objects just because I feel like it. For that I'll be adding in tiles and whatnot.

Now something about this engine is, since it's designed to run in a browser I decided to just code the game for the tiles to be double the size of regular zelda game tiles. I can easily adjust them to be small, but why scale up when I can run it at a playable size natively right. With this in mind, I thought it was pretty lame when I just doubled the size of some lttp tiles, so I've been playing with some original tile graphics to work with my big tiles:



Not sure about the palette yet, but I like what I've got going.
Logged
Re: Web Browser Engine
« Reply #9 on: July 09, 2011, 08:47:46 am »
  • AKA "Micah DS"
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1347
Very awesome. And I only found one glitch and two inconsistencies (I'm using Firefox 5)! I've attached a pic of the glitch.

The glitch:

All you have to do to get this to happen is to press into the left wall (only happens on left walls), let off of the left key, then press and hold grab and immediately following press and hold the right key.

Inconsistencies:
1) On the stairs, you can grab the left wall but not the right wall?
2) If you are traveling across the ice bridge and you hold into an edge to jump off, you are only supposed to jump if there is nothing in front of you. This works fine. However, if you are traveling across the bridge and you hold into the edge AND press grab, you can jump down if there is half of a block a block or less in your path.


Maybe it's not a big deal, but I thought I'd point those things out.

I only played this for a couple minutes btw, but I'm usually strangely lucky (?) at finding glitches and stuff like this.
« Last Edit: July 09, 2011, 08:54:15 am by Frozen炎 »
Logged
  • My Music
Re: Web Browser Engine
« Reply #10 on: July 09, 2011, 11:14:31 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
Thanks a lot, that's very helpful. I'm not sure what you mean by the bridge jump though The criteria for jumping from a bridge to ground is: if there is set of co-ordinates in the jump direction at a lower z-index with no tiles of a higher or equal z-index in between. Also that you are not standing on bridge transition tiles.



The red is places where it's supposed to let you jump down, which seems to be working as intended for either pushing or holding X to jump. If it's different to that can you attach a screenshot, I'd appreciate it. :)

If anyone else finds any bugs not listed I'd like to hear about it, thanks.

Known bugs:
Ice and water movement momentum can seemingly gather indefinitely when running back and forth.
On ladders you can grab left but not right
You can grab onto left walls and quickly change direction to grab thin air on the right





Logged
Re: Web Browser Engine
« Reply #11 on: July 10, 2011, 01:22:08 am »
  • AKA "Micah DS"
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1347
Thanks a lot, that's very helpful. I'm not sure what you mean by the bridge jump though The criteria for jumping from a bridge to ground is: if there is set of co-ordinates in the jump direction at a lower z-index with no tiles of a higher or equal z-index in between. Also that you are not standing on bridge transition tiles.
...

Oh, my bad, sorry about that. It works fine; no inconsistencies. Though it is a bit strange feeling to be able to jump ALLLL the way to the left if you're jumping from the top or bottom of the bridge at the top. If you jump to the left from the top of that bridge, Link will travel about twice the distance as he would from the center, since he has to clear the solids.

I get why you have it that way, but I just wanted to point out that it doesn't feel right to me when traveling horizontally (vertically seems fine). Not sure how you'd fix it or if you want to. Maybe it just looks weird to me lol.


Also, I have noticed that the ice is a bit off in momentum, as you already pointed out. When I turned around in the middle of the ice it took far too long to begin traveling in the opposite direction. Link was running in place for about 4 seconds.


With those things said, it seems pretty solid and it's a very interesting project. I'm looking forward to new updates for sure.
« Last Edit: July 10, 2011, 01:23:52 am by Frozen炎 »
Logged
  • My Music

.

Re: Web Browser Engine
« Reply #12 on: July 10, 2011, 03:24:32 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Posts: 143
Actually, you shouldn't be able to jump off the bridge at that point. The view (3/4) uses 3-dimensions, but people see in two dimensions and light is shown from a monitor in two dimensions. This means that the apparent x and y-values of the objects change even if only the z-value changes. This causes the character to appear to move north, south, east, or west when moving up and down. Normally when jumping over an edge, your x or y-values change only slightly, so the large change in position is an effect of the changing z-value. Jumping at that point causes your x or y values to change more than normally and not your z-value. The edge must be facing the same direction the jumper is moving in. Since I'm never able to describe anything simply due to my necessity to describe everything in great, somewhat repetitive detail to avoid misunderstandings, ultimately creating more confusion, I will also explain it visually.
Logged
Re: Web Browser Engine
« Reply #13 on: July 10, 2011, 04:05:32 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
Actually, you shouldn't be able to jump off the bridge at that point. The view (3/4) uses 3-dimensions, but people see in two dimensions and light is shown from a monitor in two dimensions. This means that the apparent x and y-values of the objects change even if only the z-value changes. This causes the character to appear to move north, south, east, or west when moving up and down. Normally when jumping over an edge, your x or y-values change only slightly, so the large change in position is an effect of the changing z-value. Jumping at that point causes your x or y values to change more than normally and not your z-value. The edge must be facing the same direction the jumper is moving in. Since I'm never able to describe anything simply due to my necessity to describe everything in great, somewhat repetitive detail to avoid misunderstandings, ultimately creating more confusion, I will also explain it visually.

Yeah you're right. It's kind of a quirk of the engine rather than a bug though. Maybe I can add in a check that if there's a series of unwalkable blocks that don't technically go higher but are static for say four blocks, don't allow the jump. I'll jot it in the additions plan.
Logged
Re: Web Browser Engine
« Reply #14 on: July 13, 2011, 04:28:44 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
Version 0.26 is here!

Changelog:
Fixed ice/water movement momentum bug
Fixed various inconsistencies/bugs with grabbing
Changed jump physics. Now when jumping from bridges up left or right you can only jump immediately down, this feels much more natural.
Changed tile size to regular zelda engine 8x8 instead of 16x16 and adjusted speeds and offsets accordingly.
Added health & HUD heart translation
Added hurty spiky tiles that drain health (debug red)
Added changable variables for ability items, currently whether we can swim and dash or not.
Added proper swimming transitions to facilitate stopping swimming
Added debug controls for abilities and health

The new water transitions are fun. A bug I noticed when adding the little jump was that when dashing the movement speed wasn't reset by the jump-into-water speed, so you jumped way too far, which if there wasn't many water tiles in front of you left you swimming in the floor. Instead of fixing it I decided to add a check when you're done jumping that checks if there's no more water and cancel it. Hey presto, if you have dashing and not swimming you can jump small bodies of water! Try it on the river on the left. :D

I've abandoned the whole custom tiles of bigger size thing because I stopped having fun making tile graphics pretty much immediately. I've moved on with the intention of using lttp tiles for the time being. Hence the move back to 8x8. It has to be scaled up now to not be tiny on the screen, but eh, maybe later.
« Last Edit: July 13, 2011, 04:31:26 pm by DeadMint »
Logged

.

Re: Web Browser Engine
« Reply #15 on: July 13, 2011, 05:33:09 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Posts: 143
AAHH! Screen resizing causes anti-aliasing!
Logged
Re: Web Browser Engine
« Reply #16 on: July 15, 2011, 10:47:05 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 8
Yeah, I can turn it off in firefox, which I will. The others decided that no-one should ever need to be able to choose the rendering mode themselves and actively didn't include it, pain in the ass. Hopefully they will follow suit of firefox and include it sometime soon.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.319 seconds with 69 queries.