Sunday, October 2, 2011

Code::Blocks(17) RPG 4 - Rpg Demo working, Player creation end.

A preview before starting the networked part:

I have made so many changes in the code that it's gonna take very long to post all them, so what I'm going to to is to make a list with updated things:

<Engine class:>
  • I have added 3 fonts to the game, they only change in size so they can used for main tittles or the plain text in the game.
  • TextOut function to draw text.
  • IntOut function to draw numbers
  • FillRect to fill a rectangle with a color
  • Window function to switch between windowed / full screen mode
<Player class:>
  • Accel, Speed, Angle variables added
  • Now the player's point of view is defined by an angle, an the movement is based in that angle, when you press <forward> player speed will increase by it's accel value (to a limit) and move accordingly to that.
<Timer class:>
  • Needed two timers in the game so I found the easiest way to use them was to encapsulate into a class, now I have a timer for FPS calculation and another to regulate framerate.
<Text Input class:>

  • A new class used to grab input from keyboard and add to a string (Used to write player's name)
 <Game class:>
  • DrawMap: In that function I have made a small but very important optimization: it drawed all the tiles in the three layers in the map but that was a mistake because not all the three layers were filled, only the first one, so what I did was to check in 2nd an 3rd layer if the tile was empty and then if it isn't, draw it, a simple change that made the processor use change from 99% to 30%, not too bad!
  • ShowStats: a function to draw player stats (name, attibutes, skilss..)
  • DrawGUI:To draw player's life and magic points
  • DrawDir: To draw a single dot in player's point of view
<The textout and intout function had a nasty mistake that was leaking memory very fast, it was a bug hard to find but now it's corrected, the game only uses 3.4MB ram in my ubuntu 32bits computer.>

No comments: