Archive for June, 2011

Text Rendering and Menu

June 26th, 2011 No comments

Now that I’ve got most of the core elements of the game finished, I’m actually doing some work on the game itself. I decided I’d implement the menu that I’ve been using as a test environment so far. The process was extremely easy and fast due to my previously implemented systems. The entity system and image systems are cleared, memory is freed, and the next scene is loaded.

To accomplish this, I used a simple vector of SFML string objects to add a simple but nice looking mouseover colour change as well as the actual detection what text item was pressed. At first I was having issues pointing to my entity manager cleaning code which scared me somewhat, but it turns out I forgot a simple check if entities existed at all in the Game scene.

What came to mind with the menu was to implement a Text Manager to go along side my image, scene and entity managers. I figured that since there were only 3 lines of text I wouldn’t bother.

I’m also aware that these big walls of text aren’t very exciting to look at, but a game of Breakout isn’t very exciting to look at either, neither is source code. Maybe I’ll post an image of the final version. I suppose this is just for those who are curious in how I’m writing my program.

Categories: Me, Programming Tags:

Collision Response Tweaking

June 25th, 2011 No comments

What I did not expect was for this process to take the time it did. Surprisingly the most difficult thing about breakout is calculating a predictable response from the ball hitting something. For the boundaries around the game area, I simply reverse the X or Y direction depending on which wall was it. For the paddle or the bricks it’s not so simple.

Part of the expected functionality is to have the distance off the center of a brick or paddle affect the rebound effect. To make it even harder, velocity of the paddle also affects this. Fortunately, yet another expectation is that horizontal speed should never exceed vertical speed, making collision response a little more manageable.

What I initially worked out as correct calculations turned out to be misleading me, as I forgot that I centered the position of objects rather than using the top-left position during my little calculator session. Fortunately I got that working. My testing environment strangely enough was the menu rather than the actual game area, as my menu will consist of a paddle hitting the ball around the screen. What also didn’t help was the fact the normalisation function that came with a sub-set of SFML’s library didn’t work, although manual calculation of this fixed this quite quickly.

Now that is sorted, I should be able to add bricks in with simple for loops and increment a score. Although the difficulty curve is now beyond the peak for this project, it makes me somewhat nervous for the recreation of Pac-man, with AI and path-finding which I have had very little experience with, regardless of having planes, boats and soldiers roaming around an island in a 3D environment. At least I don’t have to worry about calculating the direction of Pac-man bouncing off walls.

After 2 days of work I have a paddle and a ball on the screen which isn’t particularly impressive, although this was mainly due to mathematical confusion that took place. The structure of all important entities are done so far except for elements such as menu systems and a highscore system. File handling isn’t exactly new to me, although doing things without the aid of external physics or GUI libraries I’m exploring things from a whole new perspective.

Categories: Me, Programming Tags: , , ,

Image System, Scene Manager & Memory Management

June 24th, 2011 No comments

I’m continuing to expand my code base for a project due in two weeks. The idea is to create a simple game of Breakout using SFML. The idea is easy and likewise the coding shouldn’t take very long. Surprisingly I actually spent the last 5 hours working on a base for it without even a single thing on screen.

Essentially what I’m writing is somewhat of a subsidiary of SFML, or at least close to one. Closer to the end of my current trimester I’ll most likely be using the some functions that I’m writing now for a Pac-man project which will be somewhat more challenging, despite having some 3D interactive work done in the past.

Memory management is currently done efficiently and everything is handled quite well, regardless of the fact there is no actual game content. I have been using some resources from a previous test environment that’s responding well to it anyway. Sprite images are remembered within a vector class that can clear memory on scene changes as well as the previously mentioned entity system which has been modified to a fairly great extend. Entities and scenes are both handled with polymorphic abstract base classes and have been introduced with singletons and monotone design patterns.

The majority of time spent was the process of eliminating strange memory issues that have now been solved, making the future process of getting elements of Breakout working significantly faster. It’s possible I’ll have a prototype of the project by the end of the next time I work on it unless I get sidetracked on specific features. I’ve laid out skeletons of the ball, brick and paddle components as well as the three game scenes that I’ve planned which I’ll most likely start some time tomorrow.

Categories: Me, Programming Tags: , , ,

An Entity System

June 22nd, 2011 No comments

As part of an exercise using SFML I received a rather simple task of collision detection with rectangles for the week, as well as the use of some vectors (In this case point-based, not array-like vectors). What I did initially was create a player instance and a few ‘buildings’ for collision testing.

What I also did was incorporate a little entity system that I’m quite happy with. The only thing required to add an entity now is entManager.AddEntity(entity_type,xPos,yPos,<sprite path>). Although this would seem rather limited it does everything I need to do for a while. The difference between this and my regular work is that regardless of using SFML, it does not restrict anything from the programmer and in this case there is no such thing as an entity system already.

An abstract base class, in this case a WorldObject serves as the base of each entity type. It assigns a collision rectangle and a unique ID. This way, I can add as many instances of an entity without having to worry about naming problems, and the collision system is automatically set up as well.

Right now I’m using a static cast to convert the ‘WorldObject’ that the player class inherits from back to the player, which might not be the greatest design method but it works.

The Witcher 2

June 17th, 2011 No comments

I’ve been somewhat busy with Uni and haven’t done anything exciting enough that seems worth sharing. Duke Nukem Forever came out, something that no one saw coming after 15 years, but I suppose hell really does freeze over. While I struggle with simple 2D vector transformations with no game engine to help me do it, and 12 weeks of 4-spacial dimensional Quaternions and Euler angles coming up next trimester I have some stuff to learn.

Meanwhile, I also played a game titled ‘The Witcher 2’. Surprisingly I hadn’t played the first game, but this was something I did almost immediately upon playing the second. Now I’m no game reviewer so I’ll keep my thoughts short. Despite having some nasty little difficulty peaks here and there, mostly due to my own lack of skill at RPGs, it’s blown a lot of other games out of the water completely. It’s also surprisingly non-linear despite ending up with a linear storyline overall. Choosing a different sentence to speak doesn’t simply affect the conversation, but the entire series of events that occur for the 30 or so hours of gameplay are effected even from the start of the game. The game follows closely to a series of short stories, which I am now also tempted to pick up and read; an activity which I haven’t done for a long time.

Graphically the game manages to easily outdo even the 2007 flagship Crysis, with other newer titles not far behind now. Storywise, I was sold completely, and it really immersed me into this completely new world which is not something that occurs much from games I play. Oddly enough, both this game and its predecessor seem to have a rather strong theme of.. er.. clothe-less experiences.

Categories: Me Tags: ,