Pages

Sunday, December 2, 2012

Visualization of A* Algorithm - A Java Project

As I mentioned in the last post this semester I'm doing a Java project which is Visualization of A* Algorithm. Because of the exams, I couldn't spare time to improve it. I did some in this weekend. I redesigned the class structure because a class was doing things that it shouldn't do. I added one more class and it is more object-oriented right now.

When I did the first version - before the improvements above - I showed it to my professor. He wanted me to add the spreading of the algorithm in every step. In this way, we are able to see how the algorithm works. To do this, I had to sleep the algorithm for awhile in every step. And I added sleep into the function which finds the path. But it didn't work as I expected. Because GUI slept, too. After a little search, I found that I had to make thread programming to fix that problem. My program was executing in a single thread, when I sleep a function, GUI was sleeping, too. The thing that I have to do was dividing the program into two pieces, first is the piece that shows the GUI elements and the second is the piece that does calculations for algorithm.

I know a little bit of thread programming from my Operating Systems course. We also did a lab to learn better. We were using C, you can find the code for that here. In Java, thread programming was easier than I thought. After doing that, program was working correctly.

Now, I have to study to understand algorithm better. I am little bit confused because of heuristic part of algorithm. The heuristic is directly affecting the algorithm, choosing the right heuristic is the main issue of A*.

Here is some images from the project;


Initial position of starting and destination nodes. Later, users will be able to change their positions.



Spreading of algorithm. Light gray nodes are in closedList. Dark blue nodes are in openList. Calculating g value of neighbors is like this:
currentNode.g + 10 for horizontal and vertical neighbors
currentNode.g + 14 for diagonal neighbors
And Manhattan heuristic is used.

When I finish this project, I'm planning to open the source code. I will probably share the codes on Github.

Saturday, November 3, 2012

Long Time No See

I haven't written something for more than a month. I have reasons for that. I've been busy with some paperwork for senior-year project which I will give more information in another post later.

What am I doing?

I'm busy with loving my Unix class. I always wanted to go little deep on the subjects of Unix. This is being happened in my Unix class and I'm happy with that. Moreover my professor gave me a GNU sticker. Woohoo!


I'm also spending time on my Java project which is a course project. I'm doing Visualization of A* Pathfinding Algorithm. We'll submit this project at the end of the semester. But I started early and did some improvements. Actually, this algorithm was another thing I always wanted to learn. I knew that this is also highly used in games. That's why I wanted to learn.

Finally, I will share a screenshot of that project which is an inevitable ending of my posts.


Sorry about the color choices. Green node is the starting node, red one is the destination node. Yellow ones are the walls that the path cannot pass through. Pink ones show the shortest path. User will be able to change the places of starting and destination nodes. Also they will be able to put walls wherever they want. 

Thursday, September 20, 2012

G.I.F.T.

As I promise, I'm going write something about my new game: G.I.F.T. actually new version of the ice cube game. In G.I.F.T. we are controlling a kid and helping him to get his gift. Base mechanics remained same. We are controlling him by sliding on the surface. I've uploaded the game on kongreate and newgrounds. (Kongregate link - Newgrounds link to play the game.)

Here is how I converted an old game to a new one.

First, I started with changing the character. I wanted it to be a kid. And I started to draw something. First, I thought the kid as a stickman figure. But I didn't like that and I changed my idea. Then I applied some colors and I got this result:


This was my first attempt to draw something for my game.

Than I started to make tiles. In my mind, there was winter atmosphere for the game. For that reason, I made snowy tiles. And I used gradient effect for the background image. This is the tileset that I've made:


And a snowball which is an obstacle:


I know that they're not so good. But making them was so fun for me. Also, using them in a game was a great experience.

I also made some jumping sounds. It can be hardly noticed because its volume is low. That's because I recorded them by using a cheap microphone.

Now, some technical stuff:

I made all the levels as a different class which derives from FlxState. I chose this way because reseting was too easy. Just a line of code which is FlxG.resetState(). But I couldn't put a loop music to the game, because when it resets the game, it also resets the music. For that reason, maybe this decision wasn't that useful. I think whole game must be in just one state to fix this problem. Reseting can be done with setting all variables' values to thier first values. Another bad thing is that I wrote almost same things for the all of the levels. In the ice cube project, I wrote a Level class and derived all levels from this class. I think this way is better and more object-oriented.

I hope you have fun while playing G.I.F.T. and please rate and leave comments.

Monday, September 17, 2012

Ice Cube Has Gone

From the beginning, I didn't like the idea of ice cube game. But I liked the base mechanics of it. For that reason, instead of making new game I wanted to change and enhance it. I've been working on it for more than a week. The game has changed entirely. I think it's better than the previous idea.

I will give more information about the new idea soon. For now, I'm putting an image which reflects the game directly.



Tuesday, September 4, 2012

JURUMP - My first game

Yes, Jurump is my first game. Me and Efe Alaçamlı made it together. Click here to read his blog post about Jurump. (Link for the game is below this post.)

We made this game in fall, 2011 for the course called Introduction to Computer Games. This is the course which I meet game programming and love it. Obviously, this was my favourite course, I always looked forward to this course whole week. Other than those, another thing that I remember is how excited and enthusiastic I was. I hope these never ends.

Let's talk about the game now. It's side scrolling 2D platform game. We are trying to save Ali, who is the main character, from alien invasion. He is on the roof of the buildings during this escape. He shouldn't fall into the gaps between buildings and hit aliens. Also, there are four bonuses he can take. These are super jump, temporary protection, speed up and whistle. The goal of the game is finishing the levels faster.

We programmed this game in Java and used Slick2D library. This was a good and rough experience. I remember that we had trouble coding jumping. Because we wanted to simulate gravity in a right way. The character was shaking when he touches the ground. But we did some value changing and solved the problem.

And finally this game came out:


We made this "How to play" screen but some people didn't go there and they never used the bonuses. 






Click here to download the game. Java gives security warning, click no to play. 


Saturday, September 1, 2012

An internship ends

It's been two weeks since the internship ended. But I can have a chance to write something at that moment. I've been busy with writing report and other stuff. In this post I will write about internship and the game that I made in this period.

Little information about game: It's a 2D platform game. The character is an ice cube. We're trying to get him to the north pole to make him live free there.

In my previous post I wrote

I'm having trouble designing the levels and making these levels hard.

As I wrote, I really tried to make the levels hard but when I watch people playing my game, those levels were VERY VERY HARD. They could finish the levels and proceed the game. I designed the difficulty of levels for my ability which was totally wrong. Because, while I was making the game, I played it a lot and I got used to controls and eveything. I understand that I missed a very important point which was playtesting. I should have done more playtesting. Maybe, the levels were not going to be that hard. I will put the game here, but I need to do some arrangements.

The game has lots of missing things. It's not fully completed (like my other game-ish things). But this time, there is a little bit much. Maybe I tried to complete some of them. But I really don't like to deal with a project after its deadline has passed. I rather want to make new things.


An image from third level

There are three weeks for college to start. Until that time, I want to find a game idea that I satisfied. Also I need to think something for my senior-year project.

See you soon.

Sunday, August 5, 2012

Ice Ice Baby

                                              
(This ugly image of an ice cube is drawn by a developer who tired of using placeholder one-color images.)

Second week has passed. Sometimes I enjoyed coding, sometimes not. Anyway, I implemented some features.

Here is the list of things I did and some thoughts:
  • Flixel is really cool library. For example, making fade in/out effect is just one line code. (Flash effect is that easy, too.) Also, it has a nice documentation.
  • Dame is also cool. If you export as a CSV file, your code will be much smaller.
  • Character controller, movements of the traps were coded. You can see those in the GIF. (I couldn't make the GIF properly. Actually, they are moving well.)



  • I tried to design some levels. It was really hard. I will work on that later.
  • By the way, I'm having trouble reseting the game after the ice cube dies. Deriving levels from FlxState is a solution, but I do not like that idea. Because I have to change the level switching also. If I do that, I have to add the character before every switching. (Maybe there is a solution but I couldn't find.) 
There are 2 weeks to the end of the internship. I hope, I'll finish most of the game.

Sunday, July 29, 2012

Finding a Game Idea


I'm an intern in a game development company. During the internship, I'm going to do my own project.

First I needed to find a game idea and I started to think. Finding a game idea from scratch is REALLY HARD. Nothing came to my mind. Then, I decided to choose a theme and make a game on that theme. I went this site and "Ice/Igloo" came out as a theme. I got rid of the "igloo" part because I thought that it was very specific. I needed more general theme. 

I chose an ice cube for the main character. And I started to think about how the base mechanics is going to be. When we control the ice cube, If we press left for example, it's going to keep continue to go in that direction because of slippery surface of the ice cube. And the ice cube is going to melt, so we have to finish the level without melting completely.

After the base mechanics, I thought the story and found this:

Every ice cubes want to get rid of their ice cube tray and be free. The heaven for them is the north pole. They can enjoy the freedom in there without the idea of being in someone's drink.

Our character is also chasing this dream.

But it’s not that easy. You have to be so lucky. You have to wait somebody to cool his drink and take an ice cube. When he tries to take out, you have to pop out and run away instantly before the guy gets you.

After all that stressful experience, a new adventure is going to begin for you. You need to go north pole before melting completely. Also you’re going to have hard times with moving because of your slippery surface. There will be some traps which make you melt so fast. You need to be careful.

After all that difficulties, you are going to get your freedom.

(I think the story is not too bad.)

Here are the other decisions and thoughts:

  • I'm having trouble designing the levels and making these levels hard.
  • I tried to write high-level design document. Some part of it was really boring. It is still uncompleted.
  • I'll make this game in Flixel. (Making 2D game in Unity is really painful.) For the map editor I'll use Dame.

Monday, July 2, 2012

Video and Webplayer are here



Gameplay video of the last version. Most of the problems were taken care of. You can play it here.

I'm going to take a break and I'm not going to work on that game for awhile.

I have some other ideas. Maybe I'll work on them.

Wednesday, June 27, 2012

Still working on

Since I've been in vacation, I couldn't do some things as I planned. In this period, I  added some codes, almost everytime it crushes something else. Finally, I made a short and playable version.
Here are the fancy properties of the game so far.

  • Two different towers, rock thrower and electric thrower. I used this example to make the electric effect.
  • There are five waves. After each wave, enemies are getting faster and having more health point. (Number of waves can be increased easily.)
  • Requiring money for upgrades hasn't been done yet. It's disabled for now.
  • Detecting and shooting the enemies is perfectly fine. (That means I haven't found a bug yet.)
  • Buying and selling towers has been done. (We're selling the towers the price that we buy. But it should be less. I'll fix that later.)
  • Ugly GUI that shows wave number, number of killed enemies and total enemies and number of enemies which reaches the end of the path is done.
  • Going next wave is working.
  • Game over condition is done. If ten enemies reach the end of the path then game over.
  • Also "Congratulations" screen will appear if the game is finished succesfully.


Electric tower is shooting the damn enemies.

Thursday, June 14, 2012

Money Money Money


Primary version of the buying towers system is completed. I also added a label that shows total number of enemies and number of enemies that are killed. Click the picture to enlarge.

Monday, June 11, 2012

Neater is Better



What did I do?

  • Finally, I solved the problem of tower placement. Instead of using Camera.main.ScreenToWorldPoint(Input.mousePosition), I used Physics.Raycast to find the coordinates to build tower.
  • I added health bar over enemies. But it's position is not consistent (Because of different resolutions). I will fix that problem.
  • I deleted the ellipse-like shape under the tower to detect enemies. I used Physics.OverlapSphere, instead.
  • I added enemy spawner.
  • I created a transparent clynder and made y scale value very low. Thus, I obtained a circle. I used it to specify the fire range of the tower.

You can play this version of the game here.

Saturday, June 9, 2012

Wednesday, June 6, 2012

First Steps




What did I do?

  • I created a terrain by using "Paint Height". 
  • I used way points for movement of enemies. They're red cubes for now. 
  • The ellipse-like shape under the tower shows the range of that tower. If an enemy collides with it, tower starts to shoot the enemy. 
  • Choosing enemy to shoot is not stable. This is because I'm using OnCollisionStay, I guess. I need to work on that. 

ToDo List:

  • As you can see on Project and Hierarchy view, there is no such thing as file organization. Name of the files is so irrelevant. I need to organize those. 
  • I'm using the version 3.4.2. I want to move the project to 3.5. I think, it's not going to be a big problem. 
  • Finally, the places of towers are not going to be set as game starts, Users will put them wherever they want.

What's going to be in this blog?

As soon as my final exams finished, I started to make a tower defence game in Unity. In this blog, I will share the process while making the game. The reason that I decided to make tower defence is I wanted to learn the mechanics of the tower defence games.

I will use Unity3D engine but I have some problems with finding 3D models. I will use primitive models like cubes, spheres for now.

See you soon.

Sunday, February 19, 2012

C ile Multithreading Örneği

Geçen dönem İşletim Sistemleri dersinin en heyecanlı lab dersi Thread konusundakiydi. Bir programın yapacağı işi parçalara bölmek ve her parçayı ayrı ayrı thread’lere paralel olarak yaptırma fikri gerçekten herkesin ilgisini çekmişti.

Labda yaptığımız örnek ise Silberschatz’ın kitabındaki matris çarpma projesi oldu. Labdan kısaca bahsedeyim: A ve B matrisini çarpıp C matrisi elde ediyoruz. Yalnız bu çarpma işlemini yaparken C’nin her bir elemanını ayrı ayrı thread’lerde hesaplıyoruz. Örneğin, A 3x2 bir matris ve B 2x3 bir matris olsun, çarpma sonucu oluşan C matrisi bu durumda 3x3 olur ve C matrisini oluşturmak için toplam 9 thread kullanılırız. Umarım anlatabilmişimdir.

Labın kodlama kısmı şöyle:


Şimdi ise nasıl derleyip çalıştırdığımıza ve çıktısına bakalım.

ozan@pardus2011 Labs $ gcc thread_project2.c -o thread_project2.o -pthread
ozan@pardus2011 Labs $ ./thread_project2.o  
28      23      18
41      34      27
54      45      36

Görüşmek üzere.

Saturday, February 4, 2012

Pygame ile Zombi Oyunu Denemesi

Daha önce de bahsettiğim gibi Pygame ile uğraşmak istiyordum. Başlangıç için ufak bir zombi oyunu yapmaya karar verdim. Şu ana kadar, temel bazı şeylerin programlaması bitti, mermi ve zombilerin hareketleri gibi.

Bu aşamaya kadar yazarken, beni biraz da olsa zorlayan kısım mermilerin nasıl çapraz hareket edeceği oldu. Bu sorunu halletmek için mermilerin x ve y koordinatlarını belli bir açının sinüs ve kosinüsleriyle arttırarak çözdüm. Bu oyunda ise o açı, asker ve hedef arasında kalan açı.

Yalnız hala çözemediğim bi’ şey var. Hareket halindeyken ateş edince mermiler falso alıyormuş gibi gözüküyor. Bu olması gereken bir durum mu yoksa göz ardı ettiğim bir durum mu hala karar veremedim.

Bir sonraki aşama için ise eklenebilecek pek çok şey var gibi gözüküyor. Öncelikle, zombiler ve asker resimleri olarak kareler yerine resimler koymak istiyorum, tabii uygun spritesheet’leri bulabilirsem. Daha sonra, silahların geliştirilebilir olması, zombilerin bölümler geçtikçe daha hızlı hareket etmesi, bazılarının bize fırlatabilecekleri şeylerin olması aklıma ilk gelenler.

Ama bu aralar Unity3D'ye merak saldığım için devam eder miyim bilmiyorum.

Oyundan bir görüntü:


Kodu çok dağınık yazdığım için koymadım. Biraz vakit harcayıp düzelttikten sonra koymayı düşünüyorum.

Görüşmek üzere.

Monday, January 16, 2012

Burada Neler Oluyor?

Bir dönemi daha geride bıraktık. Bu dönem boyunca blogu çok fazla ihmal ettim. Gerek derslerin yoğunluğu gerekse projeler fazlasıyla vakit alıcıydı. Ama bugün son final sınavının bitmesiyle hiçbir engel kalmadı ve kendimi hemen buraya attım. Bu yazıda da bu süreçte aklımda kalan bir-iki şeyden bahsedeceğim.

Geçen dönemin en flaş dersi Bilgisayar Oyunlarına Giriş oldu benim için. Garip bi’ şekilde çok sevdim. Ders projesi olarak Jurump adlı bir oyun yaptık. Dersi sevmemin sebebi bu dönem içerisinde Humble Indie Bundle’ı keşfetmem oldu sanırım. Herhalde, oradaki acayip orijinal, süper oyunları görünce ben de o tarzda bir oyun yapmak istedim. Ama tabii olaya yeni başladığım için yaptığımız oyun basit bir oyun oldu. Başka bir yazıda bahsetmeyi düşünüyorum bu oyundan.

Ee, şimdi tatil zamanı. Bu tatilde yapmak istediğim bazı şeyler var. Python’dan çok uzaklaştım, ona biraz yönelmeyi düşünüyorum. Pygame ile basit bi’ zombi öldürme oyunu düşüncem var. Git’i öğrenmek istiyorum. Geçen yaz Github’da hesap açıp ilk adımları attım ama şimdi onları da unuttum. Ve de blogu güncel tutmak istiyorum.

Bu arada sizlere son bi’ şeyden daha bahsetmek istiyorum. Kodlama yaparken veya çalışırken müzik dinlemeyi seviyorsanız mutlaka Grooveshark’ın Ambient tarzdaki radyosunu dinleyin. Mükemmel şarkılar çıkıyor. Ben sağlam adamlar keşfettim, Milosh, Deaf Center, Max Richter, M83 bunlardan bazıları.

Lamp Mien by Deaf Center on Grooveshark

Şimdilik benden bu kadar.

Görüşmek üzere.