Mar 222015
 

In a previous article, I had tried to move a XNA+Vb.Net game developped on Windows to Ubuntu.
I had limited success (I was only able to install monodevelop + monogame for C#).

This time I restarted from scratch :
-install ubuntu 14.04

-sudo apt-get install gnome-sharp2 mono-xsp4 (not sure about this line)
-sudo apt-get install libglade2.0-cil-dev (not sure about this line)
-sudo apt-get install monodoc-base
-sudo apt-get install monodevelop mono-vbnc

At this point, monodevelop (4.x) works and I can write vb.net programs.

-sudo apt-get install libmonogame-cil-dev monodevelop-monogame

At this point I can write c# monogame programs (a new template for monogame c# appears).

I then imported a vb.net monogame program and it works 🙂
I had to copy paste the monogame dll in the game folder thus.

monogame

 Posted by at 17 h 57 min
Déc 082013
 

As seen in article 19 (a platform game), I had came up with a text file format which I used to create levels.

I was about to start coding a level editor when I came on this editor : http://www.mapeditor.org/ .
This is freeware and it seems active enough.
Note : a nice thread here around possible tile editors.

I decided to use it with my current game project (a platform).
I choose the xml format (tmx format). See an example here : level .

I then had to code a method to parse the xml file.
In the process I also completed the multi-tiles to one block trick to avoid the edge-catching bug.
I also managed the texture tiling.

A class to create level in a farseer world will come in a next article.

Here below a screenshot of a level made with Tiled.

tiled

Here below a video playing this level.

 Posted by at 1 h 18 min
Déc 052013
 

Farseer has one specific not always easy to deal with : your world is meant in KMS (kilo meter second) whereas your rendering is in pixel.
Added to that, your world and rendering are two complete different things which does not make it easy to debug.

This where the DebugViewXNA class kicks in : it will render your world 🙂
This and a few other things like stats, datas, etc.

The how to use the DebugViewXNA class is rather easy :

add the project reference to debugview.xna.dll
add an imports to FarseerPhysics.DebugView
declare a _debugView As DebugViewXNA
set it up in loadcontent (for instance) :

_debugView = New DebugViewXNA(world)
_debugView.AppendFlags(DebugViewFlags.DebugPanel)
_debugView.DebugPanelPosition = New Vector2(15, 15)
_debugView.DefaultShapeColor = Color.White
_debugView.SleepingShapeColor = Color.LightGray
_debugView.LoadContent(GraphicsDevice, Content)

-use it in your draw method (after your spritebatch.end) :

Dim projection As Matrix = Matrix.CreateOrthographicOffCenter(0.0F, graphics.GraphicsDevice.Viewport.Width * DrawablePhysicsObject.pixelToUnit, graphics.GraphicsDevice.Viewport.Height * DrawablePhysicsObject.pixelToUnit, 0.0F, 0.0F, 1.0F)
_debugView.RenderDebugDataVB(projection)

A video to illustrate switching between rendering and debugging.

 Posted by at 22 h 35 min
Déc 032013
 

Recap #3 of recent articles around VB.Net and XNA :

VB.Net and Article 22 : 2 classes to handle character move
VB.Net and Article 21 : A simple 2D camera Version 2
VB.Net and XNA : Article 20 – A simple 2D camera
VB.Net and XNA : Article 19 – A platform game with FPE 3.5
XNA to Monogame part2
XNA to Monogame part1
VB.Net and XNA : Article 18 – Get text input from user
VB.Net and XNA : Article 17 – Farseer mouse joint & body from texture
VB.Net and XNA : Article 16 – Animating a sprite

Recap #2 of recent articles around VB.Net and XNA :

VB.Net and XNA : Vrooom V3 (car racing game)
VB.Net and XNA : PixDead by my 12 years old son 🙂
VB.Net and XNA : Article 15 – Screen Manager (i.e multi screens in XNA)
VB.Net and XNA : Article 14 – simple buttons
VB.Net and XNA : Article 13 – First steps with Farseer Physics Engine
VB.Net and XNA : Article 12 – Pixel collision on rotated shapes
VB.Net and XNA : Article 11 – Use a gamepad
VB.Net and XNA : Article 10 – A simple progressbar
XNA Games : how to distribute with Inno Setup

previous recap of recent articles around VB.Net and XNA :

VB.Net and XNA : Article 9 – A Pong Game
VB.Net and XNA : Vroom V1
VB.Net and XNA : Article 8 (pixel collision)
VB.Net and XNA : Article 7 (Scrolling)
VB.Net and XNA : Article 6 (move a texture, add a background, play some sound)
VB.Net and XNA : Article 5 (mouse input)
VB.NET and XNA : Article 4 (keyboard input)
VB.NET and XNA : Article 3 (draw text)
VB.Net and XNA : Article 2 (moving texture)
VB.Net and XNA : Article 1 (skeleton class)
VB.Net and XNA : Article 0 (introduction)

 Posted by at 19 h 45 min
Déc 032013
 

In previous article, I have regularly used either a rotating sprite (a car, a rocket, a tank, etc) OR an animated sprite (a walking character).

Here below these 2 classes.
You can use them in as a quick start for a game so that you dont have to bother with this part.

To use it the animated class :
declare it Dim animated As Animated
load it animated = New Animated(mTexture, 1, position, 0, 28, 32)
update it animated.Update(position, direction_)
draw it animated.Draw(spriteBatch)

Same goes with the rotating class :
declare it Dim rotated As rotated
load it rotated = New rotated(texture, _scale, New Vector2(50, 50), New Vector2(0, 0), _rotation, _speed)
update it rotated.Update(_rotation, _speed)
draw it rotated.Draw(SpriteBatch)

The animated class here : clsRotated .
The rotating class here : clsAnimated .

 Posted by at 19 h 38 min
Déc 022013
 

This time, lets add a zoom and rotating effect on our camera.

And lets re use the rotated sprite class you may have seen in Article 12 – Pixel collision on rotated shapes.

The only major change in the camera is the following where we will now use the position + rotation + zoom.

viewmatrix = Matrix.CreateTranslation(New Vector3(-position, 0)) * Matrix.CreateRotationZ(_rotation) * Matrix.CreateScale(New Vector3(_zoom, _zoom, 1))

The video.

The source code.
XNA_DEMO_20.2

 Posted by at 22 h 56 min
Déc 022013
 

In Article 16, we had animated a sprite.
Now lets enhance the demo with a 2d camera following our character creating a simple scrolling effect.
Note : a next article will cover parallax scrolling.

We will simply had a camera class.
Lets declare our camera,
then instantiate it in loadcontent passing the width and height,

cam = New camera(graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height)

update it,

cam.setfocalpoint(New Vector2(dest_box.X, dest_box.Y), New Vector2(graphics.PreferredBackBufferWidth * 1.5 + 32, graphics.PreferredBackBufferHeight * 1.5 + 32))
cam.update()

and finally use it in our draw method thru a parameter in the spritebatch.begin method

spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Nothing, Nothing, Nothing, Nothing, cam.viewmatrix)

The camera class is itself extremely simple (note that we will manage zoom and rotation also later)

Imports Microsoft.Xna.Framework
Public Class camera
Public position As Vector2
Public viewmatrix As Matrix
Dim _screenx As Integer
Dim _screeny As Integer
Public Sub New(SizeX As Integer, sizeY As Integer)
_screenx = SizeX
_screeny = sizeY
End Sub

Public Sub setfocalpoint(focalposition As Vector2)
position = New Vector2(focalposition.X - _screenx / 2, focalposition.Y - _screeny / 2)
If position.X < 0 Then position.X = 0 If position.Y < 0 Then position.Y = 0 End Sub Public Sub setfocalpoint(ByVal focalposition As Vector2, ByVal lock As Vector2) If focalposition.X > lock.X Then focalposition.X = lock.X
If focalposition.Y > lock.Y Then focalposition.Y = lock.Y

position = New Vector2(focalposition.X - _screenx / 2, focalposition.Y - _screeny / 2)

If position.X < 0 Then position.X = 0 If position.Y < 0 Then position.Y = 0 End Sub Public Sub update() viewmatrix = Matrix.CreateTranslation(New Vector3(-position, 0)) End Sub End Class

The video illustrating this.

The source code.
xna_demo_23.2

 Posted by at 21 h 10 min
Déc 012013
 

XNA and FPE is nice to play with.

This time lets start a platform game : an animated character jumping from one platform to another, collecting gems, in a wold of physics.

Some interesting point to note :

1-when my character is walking on tiles, the engine detects a collision at each edge, blocking my character 🙁
mad googling around, it seems i should :
-use joints : does not work
-use shapes : did not test it yet
-use multiple fixture for one bigger body : did not test it yet

For now, i create a circle for each tile instead of rectangles, it does mitigate (a lot) that bug : it is mostly invisible to the human eye (we see only the texture remember, not a body).

2-We want the character to jump only when touching the top of the tile, not the sides (or bottom).
Also, we dont want the character to jump while in the air.
There I have applied what seems the most common trick : a feet sensor, an extra body (not drawn) joined to my character (below) thru JointFactory.CreateWeldJoint.
When « feet » will collide with « floor » then isjumping=false else isjumping=true

3-The scenery is automatically generated from a text file (= a level) : level .
A level editor could come later.

As a whole, this is far from being perfect yet : the user/gamer experience is not optimal yet but still, I believe it is a good start 🙂

The video.

The source code.

XNA_DEMO_22

 Posted by at 18 h 41 min
Déc 012013
 

Here how far I got so far with monogame and ubuntu 13.04.
Remember I am not a linux boy. See previous article about monogame and windows.

1-install mono complete 2.1 (from ubuntu.org)
2-install mono develop 3.04 (from ubuntu store)
3-donwload and compile opentk (not sure this part is needed)
4-install monogame mpack (templates) for mono develop
5-sudo apt-get install libopenal1
6-sudo apt-get install libsdl1.2debian
7-sudo apt-get install libsdl-mixer1.2
8-test a monogame c# project

At this point you can build a c# project with monogame in ubuntu 🙂

Now for vb.net projects, I managed to create a new project but could not compile it (missing vb compiler?)
I guess I might have to look for more recent monodevelop/mono source (maybe from opensuse?)
Tip : for vb.net projects, change the file format to use when creating new projects to MSBuild (Visual Studio 2008) instead of the default MSBuild (Visual Studio 2010) From Preferences > Load/Save

 Posted by at 14 h 17 min
Nov 302013
 

Although I am having lots of fun with XNA, I decided I would give a first quick look to monogame (the opensource alternative to XNA).

I used a fresh install (3.2) which adds template to vs2010, 2012 & 2013 : here.
I then picked up a previous XNA project (Pong) and changed the project referench from XNA assemblies to Monogame assemblies.
And voila, the build executed just fine and I could run my demo again with monogame 🙂

Next attempt will be to port a project written on windows for Ubuntu.

Also need to test what the dependencies are when distributing such an app compiled with monogame (not more xna runtime dependency I guess?).

 Posted by at 13 h 26 min