PLEX Source Code Version 0.07

Leave a comment Standard

Time spent – 4 hours.

Okay, so I have the selector working now. There’s one issue with the pink color, so its not completely transparent like it should be but that’s a small fix (that I need to be on a computer with Photoshop to fix).

You can download the code under the GNU public license.

Remember that in order for it to run you also have to download the sounds that I got from Thanks guys for the nice sounds.

Put the sounds into the plex folder in their own folder called sounds. You won’t have to download the sounds again if you move them over to any other version you download.

Libmysql.dll Download

Leave a comment Standard

Okay so I might as well post this one too. You can download it, just save file as.

Alleg42.dll Download

Comments 7 Standard

I just realized that I forgot to put the alleg42.dll in my older plex source code files. If you want to run it without making it then you’ll have to download the dll and put it into the project folder. Make sure you save as when you click on the link.

PLEX Update

Leave a comment Standard

Time Spent – 3 hours

Right now I’m having a problem with the game freezing after its been on for a little while. I’ve tried commenting out the music, the build blocks function, the draw function, and several other things. None of them seem to help. What happens is the game runs for a short period of time and then it stops responding.

My thoughts are that it’s a memory leak somewhere. I’m going to download some of my older versions of source code and see if any of them freeze as well. If they do then I’ll keep going back until I find a version that doesn’t freeze anymore. Then I’ll diff the two to figure out what changes there are between them to try and track down the problem.

Another issue I found was when I tried PLEX on another computer in our computer lab that the mouse icon wasn’t showing up on the screen at all. I think it’ll be worth my while to try PLEX on some of the other lab computers until I can get the mouse to show up like it should. For all I know that’s the problem it’s having right now with the freezing issues.

PLEX Update

Leave a comment Standard

Time Spent – 6 hours

Despite the torture of being made to program over spring break I managed to get block selection working. Every time you click on the game screen it calls a click routine.

This routine checks several things:

1) are you clicking on blocks

2) are you clicking on a character on the board

3) are you clicking on the store

4) are you clicking on save game

Once it determines where you’re clicking it goes into a function to handle the particular action. Right now only the click block function works.

In the click block:

1) It calculates which block you’ve clicked on

2) It checks to see if this is the first block you’ve clicked on. If it is then this is the block you’re going to move. It sets selected block x and y variables. It doesn’t worry about the depth of the block you’re trying to select.

3) If you click on a block and the selected block x and y variables are already set then it assumes you’re trying to move the selected block to a new position. It calculates the x and y of the destination block and then passes this information into the game logic class.

The game logic class takes care of the actual manipulation of everything in the game, whereas the gameengine class has to deal with the graphics, music, and passing off keyboard/mouse usage to the right classes as the right time.

The game logic placeBlock function:

1) it checks to make sure you’re not trying to move the selected block to the same position (as it wouldn’t really move at all)

2) it checks to make sure you are not on the selected block (or any other character or item)

3) it checks if you are trying to move the selected block to a place on the board where the level below it has a tall block. If the level below has a tall block there then it extends up to the level above it.

4) it checks to make sure you aren’t trying to move the block more then x+1 or x-1 or y+1 or y+1 from the block’s x and y. This way you can only move the block one space from its original destination in all direction (forwards, backwards, and on diagonals).

4) it checks to make sure you aren’t trying to move the block to a section on the board that is completely full on all levels. Basically you can’t move a block past the height of the tallest spot on the array. You can’t select blocks below the topmost block, so it will always return the topmost block from any position you’ve selected a block to move.

5) if all of those conditions are met then it determines the depth of the block you selected. To do this it goes through all levels of the array until it finds the topmost block.

Once it finds the block it moves it to the destination position. The block’s old position is set to NOBLOCK, or being empty.

6) Finally the block is moved! The placeBlock function returns true or false for the successful block move. If the block is placed successfully it plays a falling sound, otherwise it plays an error sound.

Another thing I had to tackle in order to get block selection working seamlessly was my blockOver function. This function takes care of blitting blocks over top of the character so it looks like its BEHIND taller blocks on the board.

I added another check to see if the character is behind blocks from levels above it. One of the problems I ran into had to do with tall blocks. When you’re standing on a block on say the second level, and there’s a block on the level above you, I redraw the block on the level above after the character has moved to that position. This makes it look like the character is behind the block because it cuts off part of its body. However, what I had been doing was then drawing the top part of the block BELOW the block I just covered the character up with on the bottom of it. This makes it seemlessly blend back into the scenery.

The problem I ran into was if there was a tall block behind a block from a different depth level. To overcome this I had to make several if statements. If there is a tall block behind the block from another level, blit that. Otherwise blit the block from the same level.

Phew! That was a lot to write. In a nutshell, I now have block movement working. The only other issue I have is with the game freezing a lot. I’m not sure if this is my computer or the sounds I added, however I had the freezing problem every once in a while before I incorporated the sounds into the game.