Jump to content

  • Log In with Google      Sign In   
  • Create Account

Retro Grade

[Development][Intro][Hooded] Hooded revival in Python + Pygame

Posted by , in Hooded, Development 07 December 2013 - - - - - - · 603 views
Programming, Python, Pygame and 3 more...
Hello all! It's been a while (scratch that, a long time) since I've posted, or even been active on gamedev.net! Why? Because of Computer Science Courses over Algorithms and me working on my best project yet: Hooded!

Long-time readers will remember Hooded. It was a failed 2D Platformer I programmed more than a year ago in C++. It was the game I always wanted to make. The idea was essentially:
  • A 2D Platformer with Fluid Movement
  • Semi-Smart AI
  • Multiple levels where you get too acquire new swords with different stats (RPG-ish)
  • A Smart / Reusable Interface (A pygame engine)
So, I've completed the first bullet, completed the third bullet, and completed the fourth bullet. The caveats are: I made it easy to add in new levels and swords (Swords are just a new image and two lines of code, levels are a few lines of code and actually *making* them. There aren't multiple levels because I'm just trying to get everything else done before I focus on content), and the AI just randomly does a different thing every 5 seconds. However, adding in new enemies is a piece of cake!

Before starting, I also pinpointed what it was that made my first project to fail. Canonically, it was;
  • Lack of Experience.
  • A misunderstanding of programming good and extendable interfaces.
  • Not having a whiteboard.
  • Not having two monitors.
  • Not having a good computer.
So, I learned Python and spent a year remaking other games. I read some new books about programming and took an algorithms course. I got a nice whiteboard behind my desk. I felt ready. I got started. I still wanted to blog about my progress, however unlike last time I wasn't going to make 8 posts where I'd done practically nothing. I programmed the game for 1-2 months before making this post. Without further ado, here is hooded (Don't mind the programmer art, or the fact that my microphone makes me sound very weird):


I just watched the video and I sound 12 years old. The joys of laptop microphones :(!

What do you think about Hooded? Do you have any ideas that I can implement. Once I add content, I'm going to be fairly content with it (See what I did there)!

Python List Comprehensions! (And Python / Pygame Update!)

Posted by , in Beginners, Development 20 June 2013 - - - - - - · 842 views

Some news:

I finished Code Academy's Python track and most of their advanced non-track courses.

I've started hacking around with Pygame.

I'm finally making games again!

That last piece of news might be a surprise. I've spent most of the last few months furthuring myself as a programmer and trying to re-learn the basics. There's still a huge amount of information I don't know about Python, however I know enough to make games, so that's what I'm doing.

Currently I'm working on Pong, and I'll update you guys on that whenever I ask a question on gamedev.

Now on to: Python List Comprehensions.

List comprehensions are a nice little tool in Python which add syntactic sugar. Like lambdas, they aren't needed however their existence makes programmers lives a little easier. Let's start by comparing traditional Python list syntax with List Comprehension Syntax:

Traditional Python:
my_list = []
for index in range(1,101):
    if index % 2 == 0:
        my_list.append(index ** 2)
List comprehension:
my_list = [x**2 for x in range(1,101) if x % 2 == 0]
Just look at how much less space list comprehensions take up to do the same thing as a traditional for loop.

If you can't tell, the List Comprehension says that for every number in the range from 1-101, if x can be evenly divided by two then append x squared to my_list. Although you could accomplish this with a traditional python loop, the list comprehension is easier and just looks nicer.

What is the syntax?

my_list - empty list to store values from list comprehension in
for x in range(1,101) - values to check if statement against.
if x % 2 == 0 - If statement. All values from for statement are checked here.
x ** 2 - The value of this expression (it can be any expression) is appended to my_list when the if statement is true.

Let's look at a two dimensional example:

Traditional Python:
my_list = []
current_list = []
for first in range(10):
    if y % 3 == 0:
        for second in range(first,first + 20,2):
    current_list = []
List Comprehension:
my_list = [[x for x in range(y, y + 20, 2)] for y in range(10) if y % 3 == 0]
As you can see, it is a lot easier to use a list comprehension.

I hope that you now have a basic understanding of Python list comprehensions. They are a very useful tool :)!

Cheers :)!

[Development] Hooded Development #6

Posted by , in Development 18 November 2012 - - - - - - · 800 views

I know, I know, you want screenshots. However very unfortunately I am away from the computer all of thanksgiving week, so you'll have to wait.

I haven't been very active recently, and I'm very sorry. I've had many things to do recently, however I've freed up a lot more time this coming month. I hope to have a fun game (albeit not a finished one) within this month. To keep my mind thinking (And to learn C++11, the only book I've ever used was published 15 years ago Posted Image (I'm not kidding)) I just bought on my kindle "Learn C++ In An Hour A Day". I was very sad when I found out the new edition was the first one not co-authored by Jesse Liberty, because I enjoy his writing and was kind of scared this wouldn't be as good. I'll probably end up giving you guys a review soon, however it's looking good so far.

Also, Here's how I'm handling everything:

structs / enums

For example, I'm going to have a "Tile" struct. That will mean my vector of blocks I'm using for the board will be made of Tiles. Each Tile has a TileType (Enum), a position on the board (In X / Y, mainly to simplify collision and movement.)

The reason I'm doing this is because, well, it's simpler. I realized It's going to take many frames to play my animations (spritesheets), so I should have an Enum that holds the players current action. For instance, if the player is currently in a "Jumping" state, I'm not going to let them "jump" until they are in a "Standing" or "Walking State". This will make it so much easier to handle the players movement than the system I was originally going to use, so I'm happy that I thought of doing this. There's many more examples than the two above, however so far I believe this strategy will pay off.

Overall, I'm extremely sorry about no screenshots. I'll get you them, I promise.

Also; I just finished Portal 2 yesterday. Lots of fun was had, and I loved the characters. Now I'll get back to being productive Posted Image!

[Development] Hooded Development #3

Posted by , in Development 28 October 2012 - - - - - - · 1,412 views

Hello everyone! Welcome to the third Hooded Development update! What has been added today, I wonder? Well, right now this is what's happened since last time:

+Added Graphics Manager
+Refactored some lazy code

I'll start off with first one. I have added a Graphics manager that is responsible for containing the current Tiles for the screen's "board". (In SFML, Sprites and Images are divided. So for display purposes, I need an array of sprites whose images change depending on the position of the player. Thus, the map is updated every time the player moves.) There's a struct called Tile who contains a Tile's image, a Tile's Sprite, and a Tile's Type (labeled terrain). So the idea is that my Graphics Manager class has a 2 dimensional vector of Tiles which I change whenever the player moves.

I'm taking an approach where the player has 2 hit-boxes making it possible for him to go between tiles (No slopes for the win (Maybe next time (This is getting really nested Posted Image ))). My Collision class will handle collision, and if it finds collision it'll pass a set of points and a type of collision to my Physics class, which is responsible for determining the physics (Where the player should end up when they collide with a block / Figuring out Velocity and doing Algebra problems, the general stuff). Physics will determine where the Player should be. For pure ease of use, readability, and expansiveness purposes, there is a separate class that handles movement which the Physics class calls. Then, my Graphics Manager's Map will be set and it'll render everything where it should be.

Now to move on to the elephant in the room, the second one. My code for the Graphics Manager and the Map manager was pretty bad, so I'm still refactoring (I really didn't think through my Map Posted Image). Overall, I believe that development is coming along (albeit pretty slowly, I keep on browsing the web trying to figure things out.)

I believe these development posts are really helping me get my thoughts together and continue development. Any recommendations for handling things and / or corrections are welcome in the comments below. cheers :)!

[Development] Hooded Development #2

Posted by , in Development 27 October 2012 - - - - - - · 529 views

Hello all! Since my last hooded development post I have succeeded in loading a map from a file! Here's how I did it:
#pragma once
class Map
Map(std::string MapFileName);
const TileType& GetTile(int PosX, int PosY);
const std::vector<std::vector<int>>& GetWholeMap();
int MapSizeX;
int MapSizeY;
std::vector<std::vector <int>> MapVector;
std::ifstream MapFile;
#include "StdAfx.h"
#include "Map.h"

Map::Map(std::string MapFileName)
if (MapFile.is_open())
  MapFile >> MapSizeX >> MapSizeY;
  for (int index = 0; index < MapSizeX; ++index)
  int LoadPositionX = 0;
  int LoadPositionY = 0;
  while (!MapFile.eof())
   MapFile >> MapVector[LoadPositionX][LoadPositionY];
   if (LoadPositionX >= MapSizeX)
    LoadPositionX = 0;
  std::cout << "Could Not Load Map File:" << MapFileName << std::endl;


const TileType& Map::GetTile(int PosX, int PosY)
return (TileType)MapVector[PosX][PosY];

const std::vector<std::vector<int>>& Map::GetWholeMap()
return MapVector;

So essentially, I have my map.txt files structured as such:
8 4
1 1 1 1 1 1 1 1
4 5 2 3 5 5 7 3
8 5 6 1 5 7 2 9
1 1 1 1 1 1 1 1
The top two numbers are the X size of the file (Number of Columns) and the Y size of the file (Number of rows). Then, the numbers under it specify certain block types! Currently you can request a certain tile in my std::vector of tiles, or you can get the whole map! What do you think of this, seasoned developers? Is it smart, or is there anything I'm forgetting / not planning for?

[Development] Hooded Development #1

Posted by , in Development 27 October 2012 - - - - - - · 636 views

Hello guys! If you don't know, I've been working on a new game called Hooded. It's a Side-Scroller with some basic RPG elements that I'll be working on for at least a month or two from now. This is my first development blog! Right now I've finished the Linear Algebra and General Math sections, and the Input handler. The development is coming along nicely (I've been working on it, my YouTube tutorial series, and this blog all day!). If anyone wants a nice SFML input handler, feel free to message me, because I'm very proud of what I've made! The plan is to make it tiled and load levels from files. If I feel like going for something harder at the end of development, I might put in a level editor!