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 - - - - - - · 584 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):

Video!

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)!


[Development] I've made Pong and Breakout in Pygame!

Posted by , 27 June 2013 - - - - - - · 898 views
Pygame, Python, Programming and 4 more...
Well, I did it. Pong and Breakout in pygame!

I'm not putting Pong up, it was hacked together and I'm not very proud of it.

I am, however, putting up Breakout! I coded a finite-state-machine, a basic button GUI system, all of my states, the paddle, the ball, the bricks, all object-oriented with beautiful pygame! And everything is completely commented, with classes having long documentation strings. It comes in at a little over four-hundred lines, and the executable is here:

BREAKOUT Posted Image!

And the source (along with the executable file and setup.py):

BREAKOUT SOURCE Posted Image!

I am very proud of this code. It looks (and feels) beautiful, and I can't wait to work on some more games (I see space invaders in the future!).

I'm going to eventually write a source analysis and talk about it more, however it's pretty late and I should probably get to bed.

See you guys tomorrow Posted Image!

And I'm back! That was some good sleep!

So, I made a video of the game!

And I'm really happy with how it turned out! I'm working on adding more levels as we speak Posted Image!

A Few Hours Later - And I'm back!

I'm actually uploading the files in the morning, however there is now:

FOUR AWESOME LEVELS!
SOME BRICKS TAKE TWO HITS, AND IF THEY ARE HIT A DIFFERENT TEXTURE (BROKEN BLOCK) IS DISPLAYED!
MAPS ARE AWESOMELY GENERATED USING EITHER A LIST COMPREHENSIONS OR TRADITIONAL FOR LOOPS!
COLORS ARE RANDOM!
THERE IS A RANDOM MAP, A PYRAMID MAP, AND A RAINBOW MAP!
THERE IS A MAIN MENU!
THERE IS A GAME OVER SCREEN!
ONCE YOU COMPLETE A LEVEL YOU ADVANCE TO THE NEXT LEVEL. IF THE BALL GOES OFF THE SCREEN YOU GO TO THE GAME-OVER SCREEN!

I believe it is finished! Have fun :)!

NEXT PROJECT: SPACE INVADERS, SUPERMAN3275 STYLE!


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

Posted by , in Beginners, Development 20 June 2013 - - - - - - · 810 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.append(second)
        else:
            my_list.append(current_list)
    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 :)!


P and NP: Algorithms Part One

Posted by , 01 June 2013 - - - - - - · 946 views

I know I keep on going for two months and then saying "I'm not going to do it again!", however at least I have a legitimate reason this time. My computer broke. Completely. So, I bought the amazingly awesome, beefy, and fast Lenovo Y500 for development. I'm opening it on Monday Posted Image!

Now, I'm using a temporary laptop for small development, and I'm updating you:

Firstly, my (first) software product is being released soon. I haven't told you guys about it yet, however it is PyText! (That's not the real domain name, however the normal one is currently down so yeah Posted Image!)

Secondly, I've been working on Jarvis.

Before I start, let me say how much I'm enjoying Python. Everything is so easy and simple. No linker problems or weird compiler bugs. Everything is a module away (from, maybe, PyPi Posted Image). Python is so simple yet powerful, it has everything I like about a programming language. The syntax really is just beautiful to look at.

I'm working my way through Code-Academy's Python track and Learn Python The Hard Way, after which I'm reading one of the books about PyGame development, after which I'm reading a Python Data Structures book. After which I'll probably tackle a functional programming language Posted Image!

Jarvis is my personal voice-assistant. I've integrated him with the Wolfram-Alpha API and he's using PySpeech (on Windows) and CMU Sphinx (on Linux) for voice recognition. He is awesome. He can do everything Siri can do (wolfram-alpha), except he's on a desktop and tailored for me.

I'm currently getting a Raspberry PI and hooking up hidden microphones around my room. The PI will just be running the script (I also am going to be interfacing my script with a set of LCD lights which I'm also hooking up to show the status of Jarvis, what he's currently doing, etc.)!

I will be able to walk into my room and this will happen (with CMU Sphinx rather than PySpeech it's even better because of CMU Sphinx's grammar):

Me: "Jarvis"
PI: "Yes sir?"
Me: "What temperature is it in Arizona? It's where my parents live"
(CMU Sphinx can filter out the "It's where my parents live part")
PI: "I'm not sure, let me check. Oh yes, here it is. It's 36 Degrees Celsius, sir"

I can't wait until it's hooked up! (I'm already testing on my temporary laptop)

Now onto P and NP.

 

When discussing algorithms, we find that P and NP constantly come up. A key part of understanding algorithms is understanding both how they scale and how hard they are to solve. P and NP help us answer both of these questions.

Multiplication is considered an P problem. Computers can perform multiplication rather quickly, and it is very easy for them to solve a multiplication problem. Multiplication is a P problem because no matter how much more complex it gets, the time it takes to solve only increases by little. It is considered to be upper-bounded by a polynomial expression.

What does this mean?

It means that:

Some polynomial is greater than the running time of the algorithm.

In math:

If we have a polynomial z and an equation f(x), z upper bounds f(x) if z >= f(x) for all possible values of x.

An NP problem would be finding factors of a number. As the number gets bigger the problem gets harder and harder to solve.

Finding the factors of 20 is trivial, however finding the factors of a 100 digit behemoth? It often takes at least twenty years to solve simple factoring problems like that. In retrospect, for a computer (not considering the size of values. This is considering that this computer is equipped to store numbers with any amount of digits and that there is enough RAM) 20 * 20 relatively the same as a one-hundred digit number squared.

Now that we understand P and NP, what is NP-Complete?

Take the clique problem:

Posted Image

Try to find the largest "clique" in this. That is, a group of dots all connected together in a polygon:

http://research.rosschurchley.com/wp-content/uploads/sites/3/2013/03/monopolar.png

The green highlighted groups are cliques. They form polygons.

Finding a clique in a group of, say, 5 dots seems easy, however what about 1000 dots? It's basically impossible.

The clique problem is NP, however it has another interesting characteristic pushing it beyond NP:

We can put any NP problem through a "transformer" and turn it into a clique problem. This means we can turn a factoring problem into a clique problem and so forth.

This means the clique problem is NP - Complete. If we find a way to solve it fast enough to where it becomes an P problem, then we will have turned every NP (Hard to solve) problem into a P problem. This is a huge deal.

The even more interesting thing is that scientists believe that there's no way to turn an NP-Complete problem into a P problem, or that P != NP, however they can't figure out how to prove it. So, no one really knows if P = NP or not.

Cheers :)!


College, Stephen King, and Python!

Posted by , 24 April 2013 - - - - - - · 695 views

I have three things:

Thing One:
I'm taking a online course (from Rice university :)!) called "An introduction to interactive programming in Python!".

Thing Two:
I'm reading my first Stephen King book! The running man :)!

Thing Three:
I'm learning Python!

So yeah, awesomesauce :)!


[Intro] No, I'm not leaving C++!

Posted by , 09 April 2013 - - - - - - · 832 views

Recently, when I talked of learning Java, many people believed I was quitting C++ because it was too hard or I didn't want to push forward. And this isn't true. I'm still actively developing in C++ and learning in C++, however I'm trying to get a more in-depth understanding of C++ than Java.

And in Space Invaders news:

Not much. I've been pretty focused on Java, however I'm going to have the enemy class finished soon!

And yes, I am continuing my C++ tutorial series. I'm just spending a lot of time making sure each entry is good :)!

Sorry for such a short post, Cheers Posted Image!


[Book] CSS3: The Missing Manual Review [Undetailed]

Posted by , 04 April 2013 - - - - - - · 797 views

This will be a review of CSS3: The Missing Manual, graciously provided by O'Reilly for reviewing :)!

Before I continue, let me say that this will mainly be a review of The Missing Manual format. Rather than spend many paragraphs talking about how amazing the content is, I'll cut to the chase:

This book will teach you CSS3, Good Practices, Why it's Useful, and how you can create Responsive websites with it. I didn't read very in-depth because I already know and use CSS3, however it's a great review book.

And now on to The Missing Manual.

This is a great book format. Many technical books are either too boring, too gimmicky, or they don't teach you well. The missing manual contains some classes Gimmicks, however they're scattered and formatted well. Some examples:
  • "Notes". They were formatted to interrupt you on purpose. Rather than be tucked away, they help reinforce information while you're reading. They were very helpful.
  • Sections separated smartly.
The black-on-white format of the missing manual is used to it's advantage, with simple graphics and a great layout.

If you want to learn everything about CSS3, this is a great place to start.


Taking a step forward to Java

Posted by , 02 April 2013 - - - - - - · 847 views

C++ is a great language. It really is, and can be used in a variety of ways.

Unfortunately, it is basically like someone took a handful of paradigms and shoved them together. We've got some procedural over here, some Object-Oriented over here, some Functional over here, and oh, look, some Templates! Oh boy, will my code look like someone made a cake. Except the cake will be a mix of seven randomly-chosen flavors, which are placed here and there, with some inside the others.

Even worse, I chose Object-Oriented. Or at least, the book I learned programming from was ten years old and only had C with Classes. This would be fine in 1983, however today I'm left in the dust. With a small knowledge of C++, and a gnawing hope for something new, I set out on the path to java, littered with virtual machines, byte-code and a dash of object-oriented. Wait, about that last one, I meant that someone took the bottle of object-oriented programming out of the fridge, cut a hole in it, and poured the whole thing on Java.

I want to think that I'm taking a step forward. And in reality, I am. I'm taking a step back in C++ though. My resolution is to stop C++ coding. Of course, I'm finishing Space Invaders, and I'm going to write applications in it occasionally, however for the foreseeable future I want to forget C++. Why, you ask? Well, I want to re-learn C++.

Or, more correctly, give myself a great programming language to use (Java) in a paradigm I've dipped my toes into (Object-Oriented Programming) to create beautiful applications which utilize all of Java.

So, there you go. My opinion on me learning Java. Also, you guys should buy books form O'Reilly. I had a test, and they came through:
Posted Image


[Beginners] How to get better? Program your algebra homework.

Posted by , 27 February 2013 - - - - - - · 2,142 views

Being an intermediate developer, getting better is a huge focus of mine. I read e-books, program constantly, and follow established programming rules (S.O.L.I.D.), however getting better is still hard. I've come to the conclusion that the only true way to get better is to program (following rules from books, however).

How can you program constantly? You run out of ideas, and you still aren't ready to embark on a big project. There has to be some way to get better at programming every day.

And there is.

Program your Algebra homework. Or, if you're out of Algebra, program the lesson's on Khan Academy.

"What?", you ask. "How does programming my Algebra homework help me at all?". "What does it even mean to 'Program your Algebra homework'?".

Well, it's simple. Algebra follows rules. Repetitive rules. And what are computers best at (If you don't know the answer to this question in less than a second, go read some more beginner books.)? Repetition. Procedural programming is focused on repetition. The idea that you can do the same code many times forms the base of Computer Science.

So, to get better, and learn far more about programming (Especially design), program your Algebra homework.

What do I mean? Put what you're learning to solve, or do, or simplify into a program. You'll quickly find yourself with a large library of Algebra programs.

Want an example?

The quadratic formula (and discriminates). Why did I choose this as an example? Because it's very easy, making it a great example. All you need to solve quadratic equations is to plug in a, b, and c (From standard form:)
Posted Image
into the quadratic formula:
Posted Image
Do this every night, and you'll be a better programmer in no time.

(To see the example, download the file below. The code is in C++, however it should be easy to understand for programmers of all languages as it only uses basic conditional / loop statements, variables, and functions.)

Attached Files




[Development] DarkBASIC is Terrible, and Space Invaders!

Posted by , 09 February 2013 - - - - - - · 1,360 views

Hello all! I have had a very long absence (Okay, it was only a month, however I still feel bad Posted Image).

If you couldn't tell from the title, the first basic game I will be creating is Space Invaders!

I love Space Invaders, and allows me to flex some new graphics programming muscles, including (but not limited too Posted Image):
  • Projectiles
  • Efficient Collision Detection (There will be 20 - 25 Space Invaders Per Level)
  • File Loading (I need to load the maps from a file)
  • State Machines
  • And Pre-Visualization!
I'm in the process of planning, however I will start official programming tomorrow!

And now to explain my long absence:

In the time being, I have:
  • Learned BASIC
  • Learned DarkBASIC
  • Learned far more about JavaScript
Yes, I have learned DarkBASIC.

I have been wanting to learn DarkBASIC for some time. Originally I believed DarkBASIC was a quick way to prototype games and program graphics.

And wow, was I wrong.

Although DarkBASIC has probably helped me become a better quality, the only real redeeming quality I've seen is learning BASIC. It's a great beginner language, however it can only really achieve 2001 level graphics. It's more for learning basic graphics programming (Even then, it's procedural programming syntax is horrendous. Imagine C, however you must use:
REM User-Defined type
Type myType
  string$
  REM You can't have functions in objects, making them more like glorified containers.
EndType

REM For some reason, you must also use "End" to show DarkBASIC where your program ends, and you may
REM only declare functions after your program ends.
End

REM A function
function myFunction(x#, y#)
  returnValue = x# + y#
EndFunction returnValue
REM The returnValue goes after EndFunction (God knows why)
this code)

I imagined it as a mix of Basic, PHP, and a bad version of C.

There are so many bugs, and the people who work at "The Game Creators" don't even know how to code. They hire a new programmer to fix bugs because there sole goal is making money off new programmers who believe DarkBASIC is a good way to get into graphics.

Spoiler: It Isn't.

There are literally no redeeming quality's of this language.

Also, when you create Sprites / Images, Three-Dimensional Objects, or almost anything important involving graphics, they don't allow you to name it (At least with variable you only have to put symbols after their names or use a terribly inefficient AS command). You give every object a number.

What?

A Number. How are you supposed to tell what different objects do?

And this is why I hate DarkBASIC. It makes its users write terrible code (I don't believe it's possible to write good code using the "number" system), and advertises itself as a "professional game engine" that will help its users.

I'm abandoning DarkBASIC for normal BASIC (From what I've seen, the Graphics Libraries for plain BASIC are even better, never-mind Visual Basic), and programming Space Invaders in C++.

Also, Hooded is still on Hiatus (Sorry Posted Image)

Cheers Posted Image!








PARTNERS