OK, so a lot has happened since I last posted here.
The game is now officially named Light Defender, because I didn't like referring to it as 'the game'. Some screenshots of the game as it was a few weeks ago can be found here.
One of my friends volunteered to create art for the game, motivating me to continue with the project. I have made a subreddit (/r/lightdefender) to post news and updates, whereas this blog and my twitter account will be used to post about development.
If you download the latest version (v0.1.1), you will notice that it is very different from the roller coaster ride from which it was created! The affect of gravity on the rider was one of the first challenges I faced, and was one of the easiest as it turns out, because I didn't need to worry about how it would fit into the rest of the game in terms of code. I essentially just calculated the amount the gravity was affecting the rider in terms of acceleration and changed the velocity based on that value:
def updatePos(self, FPS, surface, enemy, shots, powerup, enemyBullets):
global lineColor
angle = math.atan(factors[self.posInt])
Acc = 15*math.sin(angle) + 1.5 - self.nitro
self.v += -Acc*5/FPS
#Acceleration changes are mostly arbitrary
if self.v < 20:
self.v = 20
distanceTraveled = 2*(self.v)/FPS
self.pos += distanceTraveled*math.cos(angle)
self.posInt = int(self.pos)
I have pointed out in the code itself that the changes I make to the acceleration value are there to increase the affect on the rider. If I do not increase that value, the rider will only accelerate by 9.8 pixels/second.
The code I have written so far is a bit messy, mainly because of my irrational fear of global variables, something which I will amend later.
Another interesting code snippet is for the rotating triangles that the enemy UFOs shoot:
s = []
realS = []
for j in shape:
# Rotates the bullets using (the equivalent of) matrix rotation
s.append(((j[0]*math.cos(r))+(j[1]*-math.sin(r)),(j[0]*math.sin(r))+(j[1]*math.cos(r))))
#Adds x and y
realS.append(((j[0]*math.cos(r))+(j[1]*-math.sin(r))+x,(j[0]*math.sin(r))+(j[1]*math.cos(r))+y))
shape = (s[0],s[1],s[2])
The code handles the shape relative to it's center and the shape relative to the screen differently because I have used a rotation matrix to move the shape. It is easier to make them separate rather than rotation around the current x,y position of the shape which would require further calculation.
That's it for now. This blog is probably not very readable or interesting at the moment, so for the next post I will try to make it more about the game design choices I am currently making rather than the techincal aspects, all of which I am sure have been documented in a better way before.
Thanks for reading,
Oscar
Playing with Python
A programming blog by Oscar Bailey
Sunday, 5 May 2013
Tuesday, 16 April 2013
An Introduction
As the first post on this blog, I feel I should explain why I have created it and what you should expect to find.
Recently, I have become more involved in programming than I have ever before because I want to explore the different areas of maths that I am currently studying at A level in a more dynamic way. I also have a large personal interest in game development and if I ever want to be part of that industry, learning a programming language seems like the best way for me to do it.
As a challenge to myself, I decided to begin development of what was originally to be a roller-coaster simulator with randomly generated tracks. I used the tools I had learned in mechanics to model the effects of gravity on the cart, specifically the current acceleration of the object and therefore how much velocity to add each time I refreshed the screen.
After successfully completing this task relatively quickly, I began experimenting with possible gameplay mechanics, such as the ability to shoot projectiles from the object based on the current position of the mouse and before I knew it, I was making a game!
Right now, I have included the most basic of visual themes (red, green and blue colours), some not-so-interesting floating enemies and a basic menu to play, quit and display the player's score. Progressing through development has helped me fully visualise the power of the modern processor while giving me a greater, yet still relatively basic, understanding of how to put a game together. I hope to update this blog with interesting snippets that I have coded, and record how the game has evolved from basic to less basic along with what I have learned!
Thank you for reading, and I hope you will visit again,
Oscar
Recently, I have become more involved in programming than I have ever before because I want to explore the different areas of maths that I am currently studying at A level in a more dynamic way. I also have a large personal interest in game development and if I ever want to be part of that industry, learning a programming language seems like the best way for me to do it.
As a challenge to myself, I decided to begin development of what was originally to be a roller-coaster simulator with randomly generated tracks. I used the tools I had learned in mechanics to model the effects of gravity on the cart, specifically the current acceleration of the object and therefore how much velocity to add each time I refreshed the screen.
After successfully completing this task relatively quickly, I began experimenting with possible gameplay mechanics, such as the ability to shoot projectiles from the object based on the current position of the mouse and before I knew it, I was making a game!
Right now, I have included the most basic of visual themes (red, green and blue colours), some not-so-interesting floating enemies and a basic menu to play, quit and display the player's score. Progressing through development has helped me fully visualise the power of the modern processor while giving me a greater, yet still relatively basic, understanding of how to put a game together. I hope to update this blog with interesting snippets that I have coded, and record how the game has evolved from basic to less basic along with what I have learned!
Thank you for reading, and I hope you will visit again,
Oscar
Subscribe to:
Comments (Atom)