Timbles & .Net

I wrote the initial prototype of Timbles using vb.Net. Now I know many people will scorn at such a thing, but the reality is, I’ve been around the block with development languages – been doing it for long enough – and nowdays, I just want to go the easiest route.

Coding with .Net and VB is pretty straightforward, and you can do almost everthing you could want with them nowdays. I initial intention was to create the prototype using .net and windows forms and the move over to C++ directx when I need to code the game proper. The idea is that it is much easier to work with the prototype before investing time in the final production software.

When doing graphics with a Windows form there are 2 things you need to do. Firstly you must create a seperate user control to draw to, the second is that you need to turn doublebuffering on on that control.


Partial Class canvas
Inherits System.Windows.Forms.UserControl

This means that you can turn doublebuffered to true for this control. Place that control on your form and that is now your render target. Here is an example paint event for that control which we will use to render the game.

Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles panel1.Paint

Dim n As New System.Diagnostics.Stopwatch

PlatformDevice.currentGraphicsDevice = e.Graphics

n.Start()

If Not IsNothing(currentPanel) Then
currentPanel.Render()
End If

n.Stop()

PlatformDevice.renderFrameDuration = n.ElapsedMilliseconds

End Sub

This code then tells the current panel to render. And all that needs to be done in there is to draw to the current graphics device.

Place a timer on your control that runs at your required frame rate, and inside the event for this invalidate your control.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Dim duration As TimeSpan = Now - lastUpdate

' how long did the update actually take
PlatformDevice.updateTime = duration.Milliseconds

Dim n As New System.Diagnostics.Stopwatch

n.Start()

If Not IsNothing(currentPanel) Then
currentPanel.update()
End If

lastUpdate = Now

n.Stop()

PlatformDevice.updateFrameDuration = n.ElapsedTicks

panel1.Invalidate()

End Sub

That’s it… you’d be surprised that you can get pretty good frame rates based on this method. More than enough for 2d games and in particulalry prototypes.

Next I’m going to mention XNA, Direct3d, and C#…

Related Posts:

Timbles

I started writing a new game recently and I thought I’d take the opportunity to talk around it rather than specifically about it. The concept came from realising that I had the ability to help Rebekah with her learning through the medium of Computer Games! Yep… I was lay in bed thinking about a particular problem Rebekah was having and thinking that I should be able to find a way to help her that would be more entertaining and thus should engage her more, when the penny dropped… I’m a software developer, and a games developer at that – so there is something I could do. I got out of bed and spent through till morning working on the prototype of the game.

It’s a simple puzzle game that I call Timbles – I don’t want to say much more than that at this stage.

After working on it for a few days and feeling happy with the general concept I let the kids play it. They love it and it seems to be doing the job. I took it into Rebekah’s school to show the lead learner and he likes it to. The school are going to work with me on it to help craft it into something that the kids could benefit from.

Related Posts:

Doomdark’s Revenge


I know it’s been a while since I posted or did anything on this project, but I finally got round to doing something again today.

Firstly, I wrote a lot of code for DDR back in October 2006, I had a good few programming sessions on it, and then as usual faded away. I coded most of the NPC’s AI; Follow Liege, Follow Foe, Go after Object, Go home, Do Nothing, Approach a Lord, Pickup Objects on their travels, and Move. I coded the moving mist and wild thing regeneration. I also coded most of the battle code… and then I got distracted by shiny objects.

Since then I’ve changed computers and compiler; so loading up the project yesterday I found that it didn’t compile in a big way. So tonight I have mainly spent all the time fixing compiler issues… and there are an awful lot of them.

One of the other problems I have had with the project is that the graphics are getting so complicated that while running in debug mode, the project runs a little slow. I’ve been putting up with it because it isn’t so bad in Release mode but slowly it has been getting me down and distracting me from the issues. It’s hard to test logic if the frontend isn’t working properly.

I’ve wanted to move the graphics subsytem to make use of the hardware. By moving the 2d logic to use 3d cards I would be able to massively speed everything up. However, I’m not a 3d programmer and again the task just keeps distracting me away from things.

I had a word with Jon Alma today who has been working on the Legends Engine and hopefully he is going to knock up a quick wrapper for some OpenGL stuff that will allow me to move the graphics forward and solve the speed issues.

So today I felt that I made a little progress…

Related Posts:

Doomdark’s Revenge

I sat down today to do some DDR code, first in a while, and spent 3 hours debugging some crashes!

Don’t you just hate it when you leave your code in a none working state! One was some bad XML, incorrect closing elements, and the other was some memory being trashed. The memory problem was due to my string class doing a shallow copy on assignment… well actually it wasn’t, but the compiler was for some reason not using my string assignment operator and instead doing it itself! Actually I have no idea what the compiler is doing at that point… grr…
|inline

Related Posts:

Doomdark’s Revenge

I just thought I’d post a progress report, because it probably seems like I’ve been sat on my arse doing nothing – which on the whole, is probably true.

One of the main goals with The Midnight Engine, was its openness… this is part of the holy grail of all game development, the data driven engine (DDE); in this case I actually think it’s particularly important.

|inline

Related Posts: