Saturday, November 27, 2010

HTML5 Gaming Library Ideas

At Øredev this year and I went to a presentation on Cocos2d for Iphone, "a framework for building 2D games, demos, and other graphical/interactive applications on the Iphone". Since I have been working with HTML5 this gave me an idea that there should be a similar library for HTML5.

This is some of the main features that I think need to be a part of it:

Scene
The Scene object should automaticaly cover the entire canvas/screen.
Holds a list of Nodes
Can hold a list of Layers
An Application can have many Scenes.
- A pause scene
- Main menu scene
- Game scene
It should be possible to have transistions between Scenes

Layers
This is an invisible container for nodes. It can be used to create layered effects such as a background layer and a front layer.

Nodes
Nodes are the objects.
Attributes
-position ( in relation to their parent node, scene or layer )
Should the position be midpoint or left corner. I think both should be possible and can be set depending on what kind of object it is we are working with. E.g. Tile(left corner), Bullet(midpoint)
Methods
-Move To
-Move
-Scale
-Rotate
-RegisterEvent

Sprite
A sprite is a type of node that has an image
Used for images and textures.

Label
A sprite is a type of node that has text
Attributes:
-Text
-Font
-Size
Methods
-Update Text

Prebuilt Nodes Structures
To make it easy for people there should be inbuilt node structures.
E.g.
Menu
-Has menu items

Node Factory
There should be a node factory that creates nodes. Similary to Strophe and Jquery
The factory could be accessed through any other node or scene to create a child node
$scene.cnode(parameters);
$node.cnode(parameters);

Identification
Should use Jquery like identification
I am using the JQuery operator $ in my example but likely it would need to be something else.
$('#apa') - Find object with Id 'apa'
$('node') - All nodes
$('.sprite') - All nodes of class sprite (and it should be possible to create your own classes.

Sequence of Actions
Like JQuery and Strophe objects (nodes,scenes,layers) should return them self if nothing else is returned. This makes it possible to to sequences.
$('#apa').rotate(5).scale(-1).move(150)
$(this).cnode(parameters).move(150).up().scale(160)

Schedule
There should be schedule methods to do time based gaming.

Physics
Could be joined with BOX2DJS for 2d physics

Director
Should be a director that controls the flow of things.

Sound
Background Music
Effects

Particle System
It would be coold to have particle system to create fire and stuff like that.

Tuesday, November 16, 2010

QTP: Connecting to SQL Database

This post describes how you can connect to a SQL Database, execute an SQL statement and loop through the results from QTP using vbscript. The process is pretty straight forward, the main issue is getting the correct connection string for your database.

In the example I am connecting to Access database Northwind. But it should be the same code for connecting to any database, just a different connection string. In my current project we are using this to connect to a IBM DB2 database and it works great.

Option Explicit

Dim connectionString, sql, cn, cmd, rs

' Connection String required to connect to MS Access database
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb;"
' SQL statement to run
sql = "select EmployeeID,LastName from employees"

' Create ADO Connection/Command objects
set cn = createobject("ADODB.Connection")
set cmd = createobject("ADODB.Command")

' Open connection
cn.open connectionString
' Associate connection object with command object
cmd.ActiveConnection = cn
' Set the SQL statement of the command object
cmd.CommandText = sql

' Execute query
set rs = cmd.execute

' Enumerate each row in the result set
while rs.EOF <> true and rs.BOF <> True
' Using ordinal
msgbox "Employee ID: " & rs(0)
' Using name
msgbox "Last Name:" & rs("LastName")

rs.movenext
wend

' Close Connection
cn.Close