Galawana Studio » tag » code

Basic JS Canvas 2D Game Programming : Game Loop, Draw, Physic and Key Input

On this post I will show you what we can get with canvas and a little javascript code. I will try to implement game loop, game draw,  simple 2D physic, and key input method with this little demo of bouncing ball. on this simple tutorial we using keymaster.js simple micro-library for defining and dispatching keyboard shortcuts in our little project.

Useful Link

Project Files >> Download Here

Game Demo >> See Here

#1 Build your HTML code with canvas tags in it.

First we must create our html file with canvas tags in it, here is our html file example.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BASIC Canvas Game Part 1</title>
//we need to load keymaster micro library here
<script src="keymaster.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
//Javascript Code goes here
</script>
</head>
<body>
<canvas id="canvas" width="800" height="600" />
<p>Use Arrow Keys to add movement to the ball</p>
</body>
</html>

(more…)

read more

Unity3D : Advance Skybox Blending for Day Night Cycle

Day Night Skybox Blending

Last time I already create day night cycle with smooth light and fog transition. now I will perfected last day night cycle  in this article by adding Skybox transition from day and night just like the demo bellow. For this functionality we need a custom skybox shader that contain 2 type of skybox and blend factor with range [0-1] type to get combination of 2 skybox texture.

This custom shader is created by Aras Pranckevicius from his article on Unify Community (Unity wiki). I use it and applying it with my DayNightController script in my previous article. Here is the demo scene for complete Day Night Cycle created by unity3D 4 Trial Pro edition.


First create new shader and name it SkyboxBlend, copy code bellow to our shader.

(more…)

read more

Windows Phone : Handling the lifecycle at two levels

weheartwp7

 

The sudden closure of the your software may trigger a series of issues, if you don’t handle these situations correctly. To make the user experience almost similar to what you would have if there would be a real multi threading it is important to handle the a couple of lifecycle event at two levels, the application level and the page level.

The application level includes the state of the entire application including everything that is not directly related to the visual aspect of the page. As an example, if you have a service running in a background thread, this may be have application-wide state that you need to save before tombstoning. For this purpose the runtime exposes four events that are raised during the phases of the tombstoning, during the startup and closing of the software. (more…)

read more