Sky Hawks Featured

Today Sky Hawks was featured on raywenderlich.com as their 2013 Reader’s App Awards most addicting game! This was unexpected and I am both extremely proud and thankful. It is an honor to have my game place in this contest and Sky Hawks was made possible by the incredibly helpful tutorials and forums found on that site. So thank you, raywenderlich.com. You just inspired me to continue down this crazy road of game development.

2013 Readers App Awards: Readers App Awards

 

(Expect an update for Sky Hawks soon)

Something I made.

20121029-184832.jpg

Shaking it up – Making your game’s screen shake

Hi everyone,

In this tutorial, I will be showing you my method for making a shaking screen effect in Cocod2D. This is a good effect to add some overall “feeling” to your game. It is like the vibration feature of an xbox controller. It’s not really needed, but adds ambience and “juice” to your games. It immerses the player more deeply into the game.

Here is how I go about doing it. All of the code should be written to affect a CCLayer, in my case, it is called GameWorld.h/.m

In your .h file, you will create three new variables:

@interface GameWorld : CCLayerColor {
BOOL shouldBeShaking;
int shakeLength;
int shakeIntensity;
}

shouldBeShaking is a boolean value that will let us know whether or not to shake the screen.
shakeLength and shakeIntensity will affect how long to shake the screen for and hard to shake the screen.

Now, in your .m file, schedule an update method like so (inside your init method!)

[self scheduleUpdate];

Next, setup that update method somewhere in your code

- (void)update:(ccTime)dt {

}

Before we go on, let me explain how this is going to work. Every frame, we will be checking whether or not shouldBeShaking is true. If it is true, then we will:

  1. offset the layer by some random amount
  2. decrement the shakeTime variable by one
  3. check if shakeTime is 0
  4. if it is, then set shouldBeShaking to false

Now, in code this looks like:

if (shouldBeShaking) {
float x = (arc4random() % shakeIntensity) - 0.5f; //Generate a random x coordinate
float y = (arc4random() % shakeIntensity) - 0.5f; //Do the same for the y coordinate
self.position = ccp(x,y); //Offset the layer's position by x and y
shakeLength--; //Subtract one from the length
if (shakeLength <= 0) { //Have we reached the end?
self.position = ccp(0,0); //Set us back to align with the screen
shouldBeShaking = NO; //Stop shaking
shakeLength = 0; //Reset shakeLength
shakeIntensity = 0; //Reset shakeIntensity
}
}

From there, you just need to set shouldBeShaking to true, set a length, and set an intensity, and your screen will be shaking accordingly.

I usually wrap those three steps up in a helper method to make things more organized.

Hope this tutorial helped someone.

1: Simple TCP Python Server

Hi everyone!  In this tutorial I will be showing you how to create a simple TCP (socket) server in the python programming language.

Lets begin:

In this tutorial, we will be using the twisted module.  If you are using a mac (like me) this should already be installed.  If you are on Windows, you may need to download it here: Twisted Web

Now, create a new document in your editor of choice (I like TextWrangler for Python) and name it Server.py

We need to import twisted, so at the top of the file put:

from twisted.internet.protocol import factory, Protocol
from twisted.internet import reactor

Now that we have everything, lets get the server up and running. Add this after the imports:

fact = Factory()
reactor.listenTCP(1234, fact)
reactor.run()

The first line creates a new variable called fact which is an instance of Factory()

The second line is where you specify what port you want your server to be “listening” on. In this case, the port is 1234.

Finally, we tell the reactor to run. (Starts the server!)

You now have a fully functional TCP server! (Albeit you can’t really do anything with it)

Run it with the Terminal command:  python Server.py

Now that we have that, I’m going to show you how to actually do something with your server.

In between the import statements and the rest of the code, write the following:

class MyServer(Protocol):
     def connectionMade(self):
          print 'A client done diddely connected!'

This creates a subclass ,if you will, of Protocol, and  connectionMade(self): will be called every time a client connects.

Add a print statement before reactor.run() saying “Server started”, or something similar.

So far, your entire code should look like this:

from twisted.internet.protocol import factory, Protocol
from twisted.internet import reactor

class MyServer(Protocol):
     def connectionMade(self):
          print 'A client done diddely connected!'

fact = Factory()
reactor.listenTCP(1234, fact)
print 'Server started, listening for clients'
reactor.run()

To test this out, run it the same way I told you earlier.  Open another terminal window and in it type:

telnet localhost 1234

If all goes well, your server window should display your client connected message!

Congratulations, you have created a very simple socket server in Python!

Please leave any comments or questions below, make sure to follow me on twitter for updates on more tutorials and tips!

Till’ then,

Tate [AllTheWay Apps]

**Read this for more defs that can be used to create a more powerful and useful server: Writing Servers

Networking Engine

Yesterday I made a good amount of progress on the networking engine, as well as the server software.  Here’s a little snapshot of the server code:

Now, a word about how multiplayer is going to work: There is going to be the simple software that you will have to download, which is the server.  Much like Minecraft, you will be able to host your own servers!  Multiplayer will also be intertwined with Apple’s GameCenter!

In other words, I’ll be posting a tutorial on how to make a simple server in python later. It will show how I am making my server (but simpler of course!)

Thats all for now, thanks, and I’ll see you all tomorrow!