Spelprogrammering III – 1st post

So, we’ve started out with a new Game Programming course, called Game programming III. We’ll be focusing on 3D programming this time around.

So, let’s have a little chat about something I’ve studied this week:

I’ve started looking at our first assignment, which is to create a binary search tree using C++. (I’ll be writing this to help me understand how a Binary Search Tree works myself, whilst also hopefully help anyone reading this understand it as well)

What is a binary search tree, and how does it work?

A binary search tree is a node based data structure that categorizes each node after their size on a left (the smaller size) and a right side (the larger size). Each node has two child nodes, one smaller (left side) and one larger (right side).

Each time a new node allocated to the tree, it first looks at the root value: Is it larger or smaller than the root value? If it is, go to the right side node. If not, go to the left side node. Secondly, it checks again is it larger or smaller than the child of the root? If it is, go to the right side. etc.

Here’s an example:

binarytree_pic

So let’s use letters for this example; if we were to introduce, let’s say Z to the tree (assuming A has the value of 1, and B the value of 2 etc.), we first check,

Is it larger than the root, F? It is, so let’s go down the right side child of F.

Is it larger than G? It is, so let’s go down to the right side child of G.

Is it larger than I? It is, so let’s add it as a new right hand child of I.

The tree would now look like this:

binarytree_pic2

The assignment requires us to create the following methods: insert, erase, search, size,
traversal_pre_order, traversal_in_order and traversal_post_order.

As I’m still just starting out with this assignment, let’s have a quick look at how to create an insert method:

So I’ve started out by defining what my method should do:

  • Check if we have a root node.  If not, we have to create a root node.
  • If the element we want to inser is less than the element in the root node, go down the left sub-tree until the element becomes a child of another node.
  • If the element we want to inser is greaterthan the element in the root node, go down to the right sub-tree until the element becomes a child of another node

Now, what if we want to insert an Element that has the same size as the Root? The element has to be ignored.

How about deletion?

This is what I’m currently trying to wrap my head around, as there is at least three cases we have to consider before deleting a node, Nodes with no children, Nodes with one child and Nodes with two Children (look at the example above, Z has no children, D has two children, etc).

This means that removing a node with no childs is quite simple, by just removing the pointer from any element linked to it, whilst when you have to delete a node with a child (that sounds morbid come to think about it), we have to re-point the value of the element we want to deletes child to the root of the element.

Example:

binarytree_pic

Deleting the letter I:

binarytree_pic3

That’s it for now. I’ve been busy writing a new concept document all week, and I’m still trying to wrap my head around this subject (I haven’t programmed for months!). Anyway, that’s a small introduction to Binary Search trees.

Spelprogrammering – Assignment – 18

Spent most of the night writing my report. Although it’s almost four or five pages long already, I’m still not certain it’s written in the way Tommi had intended.

I’m not sure if I should fiddle with the code any more, as I’ve pretty much come to a full stop when it comes to my current abilities. I might as well just spend more time perfecting the report, and making sure that it’s in tip-top shape.

Spelprogrammering – Assignment – 16 (Yesterday)

I can’t figure out how to get my gamestates to work, so – in the interest of time, I’ll leave that be for the time being. Instead I manually (hardcoded) a new level when you’ve cleared every single block on the screen.

I’ve got a few more points to collect, so I’ll be trying to add text and maybe highscores just to gain those few extra points.  

Spelprogrammering – Assignment – 15

Today I’ve managed to get the Animations for the ball that is read through a text file to work. It looks great!

I also got the directional bouncing (the x-direction of the ball changes depending on where it hits the paddle) to stop accelerating in infinitum, and works “OK” right now. It’s at least a improvement from the old code.

Back to GameStates, ugh. I’m still not quite sure how to implement this -> I’ll try to get some help tomorrow.

So, Animations added, that’s another five points. Close but no cigar. 

Spelprogrammering – Assignment – 14

Re-worked the collision of the DY/DX of the paddle. It’s still a bit buggy, but it’s more stable (and fancier) than the old version. So there’s currently two different collision checks, one for the Bricks-> Ball, and one for the Player->Ball. 

I’ve also started the groundwork for a StateManager with some help from another student. The object here is to create a Menu that goes MenuState->GameState->WinState/LooseState(With an Option to restart the game or go back to menu).

But first, I’m implementing an animated sprite in order to collect more points. I’m not one hundred percent sure of this point-system – so trying to do as much as possible (even if It’s poorly written and barely (but still) functional) seems to be the way to go.

Currently, if I’m not mistaken I’ve collected the following:

Box vs Box Collision – 5p

DrawManager – 5p

SpriteManager – 5p

SoundEffectManager – 5p

InputManager – 5p

GameObjectManager – 5p

Configuration file – 5p

Creating game objects from file – 5p

No Memory Leaks – (I’m not sure sure about this one though) 5p

aaand this individual project blog – 10p

—————————————————————————-

So that totals at a grand 50p (or 55) where 65 is the minimum.

I’ve got work to do.

 

Holler!

Spelprogrammering I – Assignm,ent – 7,8 & 9.

I don’t have the required skills to do this, as I honestly haven’t learnt enough in class. I don’t know if that’s because it’s to hard for me or if it’s just that there’s no way you can go in to this class without prior knowledge or some kind of outside knowledge (that I obviously don’t know about). 

With that said, I’m still trying.

Day 7: Worked for about two hours on getting the collision to work in a reversed engineered Pong.

Day 8: Didn’t do much. Felt hopeless and just irritated. Tried reading up on SDL online and in books, didn’t exactly help as either you’d be copying straight off or just mixing code that wouldn’t work. What the hell have I missed? 

Day 9 (In class): Worked with Viktor, created bricks and got ourselves some working collision for the paddle. We’re still both just mix-mashing code from different projects as we’re not even close to proficient enough to just create code on the top of our heads. As I mentioned earlier, either we’ve missed something, or there is absolutely no way that this is supposed to be a “no prior knowledge required” type of class. 

But, to check off our list, we’ve got a working paddle, collision with the paddle and the ball and walls.

Spelprogrammering I – Assignment – 6

I’ve caught a nasty cold. And as we all know, when a man has a cold, we’re on the brink of death.

I’m currently working on collision for our Arkanoid game, although the logic doesn’t quite make any sense to me in my feverish state of mind.

Spelprogrammering I – Assignment – 2,3,4 & 5.

Due to computer issues (I’ve not had access to internet for several days) I haven’t been able to maintain the blog properly.

I’ve reviewed the Pong Workshop Code we did in class in order to better understand how C++ works. I’ve also spent a lot of time reading up on the subject in books (more specifically “Starting out with Games and Graphics in C++“). I’m honestly a little bit lost, but I’m working on it. Right now, I’m doing everything (again) from scratch as the last Arkanoid project I was working on turned out to be absolute garbage.

Right now, I’m reading up on SDL on Lazy Foo’s website (http://lazyfoo.net/SDL_tutorials/). 

Day 2: Started a new Arkanoid Project

Day 3: Kept working on the Arkanoid project.

Day 4: Decided that I’d start over from scratch and take the knowledge from the last code with me.

Day 5: Working on the new project, reading up on SDL and C++ in general.

Spelprogrammering I – Assignment – 1

We’ve decided to make Arkanoid, a simple game where a paddle bounces a ball back and forth in order to destroy bricks at the top of the screen.

Gameobjects:

Paddle,

Blocks,

Score (GUI)

Lives (GUI)

Ball,

Optional:

Particle Effects,

Power-Ups/Downs

Things that needs to be done:

Collision,

Score Counter,

Victory/Loose Cond.

Rules:

We’ve come up with a couple of simple rules:

* Spend AT LEAST 3-4 hours a day during the holidays working on the project.

* All code added has to be commented with the following format: //COMMENT – NAMEOFPERSON

* Always inform the other person when you’re working so that no issues occur in the dropbox file.

 

 

Group members, Myself(Oskar Lidh Frykmark) and Viktor Andersson.