Sunday, November 1, 2009

Why Python kicks C right in the nuts

Program to reverse a string in C:

#include

int main()
{
char s[3] = {'a', 'b', 'c'};
int i, temp;
for(i = 0; i < strlen(s)/2; i+=1)
{
temp = s[strlen(s) - i - 1];
s[strlen(s) - i - 1] = s[i];
s[i] = temp;
}
for(i = 0; i < strlen(s); i+=1)
{
printf(s[i]);
}
return 0;
}


The corresponding program in Python:

s = 'abc'
s = s[::-1]
print s

Enough said.

P.S. : Sorry about the intendation.

Sunday, October 18, 2009

Second Prize Baby! Takneed pwned!

So finally I've uploaded a video of one of my games on Youtube. This game won the second prize in the Game Programming event of Takneek (An inter hall cult fest of IITK). I made this video using the software RecordMyDesktop in Ubuntu. Right now, its very slow as RecordMyDesktop really uses a lot of your system resources and reduces the FPS to around 5-6. I tried using other things like glc, but then I found out that it was only for applications that used OpenGL for drawing. I figured it out by first recording my own video and then recording Urban Terror (a First Person Shooter game for Linux), it played Urban Terror but didn't play my game.

By the way, the competition was full of Hall Politics. The third placed team used FPS Creator, a point-and-click type software in which you didn't need to program anything. But who cares, we won Takneek anyways.


Monday, September 21, 2009

Just Eat It!

For my next game, I was thinking of making a Pacman clone. It will be my first game with some AI in it. For it I'll be using the cocos2d game engine. This is my first experience with using a game engine instead of coding the game from scratch.

I researched a lot to figure out which game engine to use. I wanted to code in python, or some other high level language like lua or ruby. Also, I wanted that engine to fulfill 2 requirements: one, that it would help me out with all the boring rendering, input, physics etc and make it much easier for me. The other was that it should have a tile/map/level editor as I really wanted to use a level editor for my next game.

Most of the engines in my list had one of those 2 things. The engines that had the first one didnt have a tile editor while those that did have a tile editor were merely and API like pygame with a tile editor. Only 2 satisfied my needs: cocos2d and ika. I tried installing ika, but it was a pain, so I left it and stuck with cocos2d. It looks really good and easy to use, plus it has all the features.

I had a nightout today and managed to make all the starting screens basically. I will need to change their fonts and make backgrounds later on, but here's how it looks for now:



I know, I'll probably think of a better name when I get the time.

Sunday, September 13, 2009

Python Baby!

I had been suggested by a friend of mine to start using python, but I had been putting it off for quiet a while now. I finally got started with it, and within a day i fell in love with it. Its such an awesome language. Why had I not found this earlier? It increased my productivity quiet a lot. Why should I have to worry about things like memory and all the stupid syntax, when all I wanted was to make a game?

So I read a book called byte of python, and since I had already been learning python in bits and pieces for over an year, I became quit comfortable with it in a day. Then I starting using the API pygame. I coded the engine within a single day, something which I never would have achieved when I was using C++ and Allegro. It felt so good to actually see the results so quickly.

The game that I have been working on in pygame is basically a 2d racing game where you get a top view of a car and have to navigate around the track. It's a scrolling game, more of the track keeps appearing as you move around. It has single player and 2 player modes, and you can select from 3 types of cars (with different acceleration, max speed, etc) and 2 tracks. You can also specify the no of laps you want, and it calculates your timing when you finish the lap.

This is really my first COMPLETE game, with a menu and all. So I guess I'm a bit proud of it. I've also been using version control, which helps a lot.





To get the source code, click here
(you will need to have python and pygame installed)



I had also planned to make a windows executable version using py2exe, but it was too much messy stuff, so I gave it up.

Friday, July 31, 2009

A Pretty Decent First Week

It's back to the same shitty lifestyle (and the shitty mess food) , all over again for me. But seriously man, this week was surprisingly ok. I woke up on 7 on almost all days and was able to attend every single class. I also did not sleep in any of them, though I had a strong urge to do so in a chemistry tutorial in which the prof was adamant to teach us every fucking thing about the history of chemistry all the way from the 19th century. I really don't understand why they teach us chem.

However, aside from going to classes, I haven't really been doing any studying. I guess its not really required that much right now. I've just been playing cod modern warfare for the past 3 days. Its an awesome game, much better than any fps I've played so far, and kicks delta force right in the nuts. It has everything man, but most of all, it has a story, something which most DF versions lack.

I also got CS source, but I'm not playing it much, mainly because I don't know how to play on lan right now. I've tried like almost every fucking thing possible, but I just can't do it. But I asked a senior today, he said you have to do some stuff on the command line. That should do it I think.

And I also haven't been doing any project work. I had started work on an open source project, but right now I spend much of my work time trying to figure out the code.

I'll start studying from tomorrow. That's a promise.
:D

Friday, July 24, 2009

Space invaders

So after working around a week on tetris, I've finally given up on it. I have made the main game engine, the blocks fall and rotate and move and all, but I haven't completed the scoring part as yet.

I worked on pong today, and it was surprisingly easy to program, maybe because I made it as a 2 player game, so I didnt have to do any AI stuff. I've been ignoring AI till now, I haven't yet made a game with AI in it. Tankwars was 2player, so is pong, and tetris didn't need AI.

My next project will be sort of a clone of space invaders, but it will be less of a clone than the other games I've made so far. Infact, I won't even play the actual game to find out what happens, I'll just make the story and everything on my own. So I guess it won't actually be a clone. It will be my first real complete project.

Classes start on monday, which will probably limit the time I can give to my projects. And that would suck really bad, I really don't want to go back to studying inorganic chem and Mechanics of Solids. I'm having so much fun right now.

Anyways, I'll keep giving updates about my new project.
Cheers.

Wednesday, July 15, 2009

Tetromania!


So after struggling a lot with Tankwars, I have finally decided to let it go. I started with another project. I plan to make a clone of the popular game Tetris. I'm almost done with it, I think it should be fully complete in about 4 days. It was surprisingly lengthy, right now the code stands at around 2800 lines. That might be because of the incredible amount of cases and if else conditions that are required.

The game is pretty crappy and bug filled right now.

After this, I have planned to learn SDL. My first project in SDL would be a clone of the game pong. I will probably start with it when I reach campus. Meanwhile, I have been reading a book called "Essential Mathematics for Games and Interactive applications", which basically deals with the Mathematics (linear algebra,etc) and some extra stuff that you need to know before starting with openGL. Ok, its not actually required, but we can benefit a lot if we know this stuff before starting.

I really don't want to go back. I'm having so much fun in delhi, and I have probably learned more than I did on campus in 2 months.

Tuesday, July 7, 2009

I've been using ancient technology

Ok, I kind of knew my website kind of sucked really bad. So I decided to make some modifications today. The first one was to somehow get rid of frames. I heard from a LOT of people, how disadvantageous and ancient they are.

I googled for alternatives to frames, and found a website that showed 4 ways to do it. The first one was using a thing called SSI, which didn't work for me. It basically just included all the files that needed to be displayed in all the pages, instead of setting up frames for them. This is sort of like the #include used in c++ and other programming languages.

I moved on to the next method, which involved using javascript to display the links on a div section. The thing to be displayed would be included in a js file. It didnt appeal much to me, since I didnt know how to layout the div in such a way that it displayed on the left, and I was too lazy to find out how to do that.

The third method was the one that I used. It was basically identical to the first one. I used a php command in all my files to include the title and the file containing the links.

The fourth one involved using iframes.

Now, the links are on top of the page instead of being on the left. I dont know how to do that right now. It might involve formatting the div element using a css file.

Another modification that i made was removing those annoying jscript boxes. I had only included them for practice. They dont really serve much purpose on the site.



I also included the links in a table and used div to enclose them in boxes. This is my first experience with using the div tag.

Saturday, July 4, 2009

Site Updated

The feedback section on my site has been updated. Now people can enter their comments, along with their names. This information will then be entered into a database using a php script. After that, to actually show all the comments, I am using another php script to recover that information from the database.




My net officially sucks. It gets disconnected on its own every half hour. Thank god I'm not running my website using Apache on my laptop.

I went to my cousin's house and took a day off from all this. I actually spent 24 hours without my laptop, can you imagine that?

Wednesday, July 1, 2009

I finally got a website

Finally, my game is available for download. Go to my
website, then go to the downloads section.

Ok, so ever since I returned from campus, my focus has suddenly shifted from game programming to web programming. I ended up learning HTML , CSS and Javascript in a short amount of time (mainly because I had already done these things earlier).
I got some free web hosting at this website www.freei.me. It looks pretty decent. All I have to do is learn PHP and how to use it with mySQL. Initially I tried it by running Apache web server on my own laptop. However, it was too complicated, and besides my laptop doesn't stay on 24X7.

Not much else to update about. So I will leave it at that.

Sunday, June 28, 2009

More Tankwar Pics




I actually plan to make the game available for download, for windows as well as for linux. However, i'm too lazy to do that :-D
Maybe I'll upload it tomorrow, once I find out how to do it.

Back to the Normal World


Finally I have left that shithole. During the past 10 days, the heat there had increased exponentially. No wonder they have sucides in IITs. We had like the hottest water on the planet, all day long. I don't know how I managed to go though the last few days. Maybe it was the belief that I would be in Delhi in a few days, or maybe it was just south park.

My game looks pretty good right now. I drew the tank using MS paint, so now I'm using sprite based graphics instead of the traditional vector based graphics. I just needed an image creating software that I could use to draw a quick image. All I wanted was a tank image. I tried gimp too, but it seems to have a steep learning curve. I do all the cropping stuff in Ubuntu using Gimp, that shit is easy.

I have included rotation using the rotate_sprite function. The tank can now basically rotate in 8 different directions. Also, whenever the bullet gets fired at an obstacle, it gets reflected according to the laws of reflection. A friend of mine thought that was kind of lame, but I included it anyways, as I had worked my ass off to program that feature.

Also, it now has 2 screens, one for each player, and actually uses vertical and horizontal scrolling. I'm using a not-so difficult technique in which basically your temporary buffer, in which you draw everything will be of a bigger size than the window, and is drawn on the screen using blit function. It looks pretty neat.

I have started learning web designing all over again. I think I need another project for myself, whenever I get really frustrated with making a game. so I've started modifying my website.




However, I'm not too happy with the layout. I've modified it a lot. But I can't change it right now. We can only upload it when we are in campus. which kind of sucks, I'll have to wait for a month to change my website. I'm using KFTP grabber to upload the files.

Thursday, May 14, 2009

Upgraded to Ubuntu 9.04, and loving it

So for the past 2 weeks, I've been trying to get my Ubuntu figured out. The story goes something like this: I had ubuntu 8.10 fully functional on my Leneovo y330 laptop, when suddenly I was welcomed by a black screen just before login. I tried to do whatever I could, short of pulling my hair out, to make things right, but it was adamant not to run on my machine. I posted I dont know how many posts on linuxquestions.org and ubuntuforums.com, but still, nobody had any clue how to make it right. I ended up learning a lot about linux along the way, as well as about my graphics card. Today I came back to IITK. I was adamant on getting my graphical mode back. I thought all that it needed was a quick upgrade of about 330mb. How very wrong I was. I couldn't even set the network settings in the text mode. Seriously man, text mode sucks.

I had given up hope when my friend, Shivam told me about a thing called wubi. It made installing ubuntu so much easier. As I had already backed up my ubuntu data, I decided to go ahead with it. But the gods were still against me. I tried installing 8.10, but there was something wrong with the wubi. At first, I thought wubi was the same for all ubuntu versions. But actually, for every ubuntu version , there's a different wubi. I spent around half an hour trying to install 8.10 using a wubi of 9.04. After that, I downloaded the wubi of 8.10, but it still wont work. Meanwhile, the wubi of 9.04 was showing some network problems, so it wont download 9.04! Bloody ass.



I took one last shot. I tried downloading ubuntu 9.04. I had been putting this off as it was not available on dc, which meant a long and lengthy download. I fell asleep during the download( having given up all hope). When i woke up, I decided to give it a shot, and guess what! It actually DIDNT try to download 9.04 and worked with the current version! What a relief! Finally I had my ubuntu back!

Monday, May 11, 2009

The First Step


So i've been thinking of taking up game programming for quiet a while, and i decided to write a simple game in allegro just to start things out. Allegro is a free game programming library which is good for beginners. I really did not want to think of an idea, as I was more focussed on the game design/structure rather than the game idea. I chose to make the snake game. It seemed a simple, yet an addictive game.

At first, I tried making it on my own. The basic idea was simple, I would be having 3 files, one of them a header file containing the declaration of the classes 'snake' and 'food'. Another one would contain the definition of the functions of these 2 classes, and finally, the main file. However, I soon learnt that it was causing a lot of problems. I needed 1 file for each class. Also, I really couldn't figure out how to get the snake to move. I looked for some examples on the internet, and I found some really cool ideas. One of them was to keep adding a pixel in front of the snake, and deleting the one at the tail. Also, I would be needing 2 variables. Also, i needed a variable to store the direction of the front as well as the tail.

However, I still don't get how I am supposed to know when to change the direction of the tail. I'm stil working on it. Hell, who am I kidding. I spend most of my time watching How I met your mother, the IPL or on Facebook. The holidays are not the right time for work, it seems. Maybe the internship will put some discipline into me.

Well, keep visiting this blog for more updates on my game. My aim is to finish it off before the end of this month.