Friday, September 20, 2013

YouTube Update!

My YouTube channel just hit 50k views! Thank you all for your support! Stay tuned, there's a lot to come! :)

Sunday, July 28, 2013

Adventext Game Engine!

Hey guys! I know it's been some time since my last post, but...here's a new one! And, if you know some Python, a pretty nice one too...

So I have made here a text game engine in Python, which is simple and very easy to use. You are very welcome to edit any part of the code and suggest things at jimkokko@gmail.com, jimkokko5 on YouTube, @jimkokko5 on twitter or even here.

I will also make a tutorial (probably in August) on how to use this engine, in case the comments in the code can't give you enough info.

Enjoy!

Tuesday, June 25, 2013

Python Programming Tutorial #3

In the previous tutorial, we talked a little bit about printing stuff. But that's just really basic. Let's get deeper.

We can print multiple stuff together:
x = "James"
print "My name is", x


If you run this, you will get "My name is James". Try it out!
Also, since we talked about running Python scripts...if you follow my instructions, now you will be using IDLE to write and run your scripts. But you know what? Forget about IDLE. It may be convenient, but it will limit you in a lot of ways. So, from now on, we will be using the console. For starters, go ahead and download a text editor. You can download whatever you like, but I recommend Notepad++ for Windows and TextWrangler for Mac. If you are on a Windows machine, use the powershell (you can find it by searching "powershell" in the "Start" menu), and follow these instructions (check the "Windows" part) to make it work with Python. Navigate to the directory of your script using the "cd" command. Do the same on the Mac, using Terminal. If you're on a Mac and your file is on the desktop, you need to type "cd Desktop". It's more or less the same thing for Windows users. If you're having trouble with this, take a look at this link. Once you're in your file's directory, simply type "python yourfilename.py". Replace "yourfilename.py" with your file's name (duh) and include the ".py" at the end. Press enter, and your program is running.
I apologize for the hard transition from the nice and comfy IDLE to the cold and cruel console, but that's just the way it is. You may not realize it yet, but when you're getting more familiar and advanced with programming, you can't depend on IDLE. Instead, the console can give you everything you need. So bare with me on this one.

So now let's just go back to our .py file. Let me show you a couple more ways to do this:
x = "James"
print "My name is " + x # as you can see, the + does not put a
                        # space between the strings like the ,
print "My name is %s" % x


But wait...what happened there in the last line?! I guess it's time to talk about some "special characters", then. These characters are used in most programming languages, so expect to see them everywhere you go. The one you used is an "s" because it stands for "string". What you may have noticed it that it replaces "%s" with the string that comes after it; in our case, x, which is "James", of course. There are other "special characters", though, like "%d", which stands for "decimal integer" (or at least that's what I think, lol). Google them to find out more about them. There are also some things called "escape characters". Here are a couple of them:
# run these and find out what they do
print "This is on one line\nThis is on the next line"
print "This is here\t\t\t\tThis is kinda far from there"

# also, check this out
print 'Did you know that you can have %d "special characters" %s?' % (2, "at the same time")


Allright, you are most likely confused, so let's explain some stuff: Remember the backslash (\) characters you saw back there? Those were escape characters. The computer identifies them thanks to the backslash and treats them differently. "\n" is called the newline character, and it basically does whatever the enter key does on a text editor. The tab character (\t) on the other hand, simply adds a tab and indents your text.
print "You can also escape \"double quotes\""
print 'You can escape \'single quotes\', too'


You've got to be careful with combining (concatenating) strings, though. For example:
print "I have " + 3 + " apples" # this won't work
print "I have", 3, "apples" # but this will
print "I have " + str(3) + " apples" # this will work, too


What you need to understand is that you can't concatenate different data types, for example, strings and integers.

Wednesday, June 12, 2013

Python Programming Tutorial #2

So, since you've got your version of Python up and running, let's continue.

When you download a version of Python, it usually comes with three or four other programs; we don't need them. The only program we'll be using is the IDLE. So, open that up and let's get things running.

It is a tradition in programming that says that, when you learn a new language, the first program you're going to write must print "Hello, World!" on the screen. It's not necessary, but let's do this, so we can talk about some stuff.

Alright, here is a Python Hello World program:
print "Hello, World!"

[NOTE: Remember when I said that there would be differences in Python 3.0 and newer? If you use a version that is newer than 3.0, when you try to run this program, you will get an error, because they changed the syntax of the print statement to "print("Hello, World!")". Watch out for that.]

As you can see, there is the "print" function, that tells the computer to print what follows in the console, as well as some text, enclosed in quotes (""), which we call a "string" (I will talk more about that in a second).

Now, we can also add comments to the code. Comments are very useful, because they are just notes you leave to yourself or other programmers, and the computer just ignores them. Comments in Python can be added using a hashtag (#). Here is our commented Hello World program:
# prints "Hello, World!" in the console
print "Hello, World!"

Now, since we successfully wrote our first Python program, let's talk about variables and data types.

The definition of a variable in programming is very close to that one you learned in school. I like to think of a variable as an empty box, which can store one value. Later on in our program, we can change its value, but first we must declare it:
x = 0

There are some things you must watch out for when declaring a variable. First and foremost, you cannot use any keywords reserved by Python (for example, you cannot have a variable named "print", because print is a function of Python). You also cannot have a variable that begins with a number. A safe way to name a variable, is to think of a name that starts with a letter of the alphabet, contains letters of the alphabet, "_" and numbers ONLY. If your variable name consists of two words, there are many ways to declare it. For example: "myVar", "my_var". Also, keep in mind that Python is a case-sensitive language. That means that "myVar", "Myvar" and "MyVar" are all different variables.

But there are many data types a variable can support:
  • An integer (..., -3, -2, -1, 0, 1, 2, 3, ...)
  • A float (A floating point decimal number, like 3.2810378)
  • A character (A single letter, like "e")
  • A string (A sequence of letters, like "Hello, World!")

There are also built-in functions that can be used to change a data type to another, if possible. For example, test these:
print int(3.7)
print int(3.1)

x = 5.282719
x = int(x)
print x

# many people suggest that you should turn your numbers into
# strings if you plan to just print them
print str(0)

Python Programming Tutorial #1

Hello! So, since I have successfully finished my course in Python, and I have learned lots of useful stuff in that language, I've decided that I'll make some tutorials. So, here we go.

Alright, for starters, I think it's better to analyze some basic stuff. Those of you who are reading this and are more familiar with the basic stuff, just skip this. For the rest of you though...

Firstly, what is programming? Programming, according to Wikipedia, is "the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages (such as C++, C#, Java, Python, Smalltalk, etc.). The purpose of programming is to create a set of instructions that computers use to perform specific operations or to exhibit desired behaviors. The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic." A simpler way to put it is to say that programming is the way to give instructions to the computer to do things. We program computers using algorithms. An algorithm is a list of instructions the computer must follow (much like a shopping list, or a recipe). Now, to code or program (it's the same thing), we need four things:


1. A source code editor. The "source code" of a program is the code itself. This is to be seen by any people working on the project; that means that the source code is invisible to the users. A source code editor allows you to write code, and usually has some useful features, like key-coloring some important words, etc. You can basically code with Notepad, that comes with Windows, and just save your file with the proper extension (for example, a file with an extension ".c" would be a source code file written in C), but there are many free good source code editors, with a variety of useful features. An example of a multi-language source code editor is Notepad++

2. A compiler. So, you've written your code, and you're ready to see if it works. Unfortunately, that's beyond a source code editor's capabilities. In order to execute our code (aka run it), we need a program called a compiler. Basically, what this program does is that it "translates" the source code, that is words that we can understand, to binary, code that the computer can understand (of course, the translation procedure is much more complicated, and I won't go into more detail about that, as it will just disorient, discourage and confuse you). I don't think that there are any compilers who do just that; instead I think that there are many programs which include a source code editor, a compiler and debuggers (which we will talk about later) all together.

3. An interface designer (optional). From a certain point of view, we can see that there are programs which do not offer any visual feedback to the user. They are, instead, more practical. For example, let's say that you write a program that fixes an annoying bug in Firefox. Chances are, this program will just execute, kill the bug, and stop, all that in the console. There's no need for such a small program to have an interface. But if you are building a big program (or one of considerable "size"), you probably want this. Many programs/languages, like Visual Basic or Xcode make this easier, by including this to the pack of programs, as I said before (source code editor, compiler, debuggers). Other programs/languages include that in other parts that you need to import, like Python (these are modules, they will be explained later). Either way, an interface designer is essential in order to make your programs more attractive to the user.

4. Debuggers. These are programs that have to do with testing your code; they are pretty much like doctors. Most debuggers just check your code for errors. This is useful, because if you do not debug your program, and you have an error, it will just close without telling you why. Instead, when using a debugger, you can see where the error is, and why is there an error, which is very helpful. Other debuggers feature things like measuring how much CPU-power-expensive is your program, how long does the code run for and things like that. These things aren't, in most cases, necessary.

When talking about debuggers before, I mentioned errors. You must know that in programming, there are two types of errors: Syntax errors, and logical errors. As a proper language, every programming language has its own syntax and grammar. A syntax error is when you mistype something. For example, in the english language, a syntax error would be "I liek apples", or even "like I apples much very". A logical error, though, is when your code runs ok, your syntax and grammar are correct, but the outcome is not what you expected or what you wanted. Syntax errors are more serious, since you can't even run your code if you have them, but as you begin coding you will see this: Syntax errors may be serious, but they are solvable (by searching in Google, forums of the programming language you are using etc). Logical errors are very, very nerve-wracking, because you can't be sure they can be solved. And even if you do solve them, in most cases you will spend from hours to even months to do so.

But let's get back on track. In this first lesson I won't be talking about any actual Python code, I'm just going to tell you how to download and install it. It can be downloaded from here, and it is available for all platforms (I think). If you need any specific instructions on how to download and install Python, just search the website or Google for answers, although it's pretty easy to do it yourself. Also, watch out for this: If you go ahead and download the latest version, you may need to watch out for some things. Since Python 3.0, there have been some changes in the syntax of the language. I am using Python 2.7.4, because it is compatible with most modules (I'll explain what these are on future lessons), but you can download any version you want, and if you get errors, you can always Google them, or even ask any questions here. So, do that: Download a version of Python, and stay tuned for the upcoming tutorials!

Tuesday, May 28, 2013

New program out!

Hey there, what's up? I just made a new program and I thought it would be a good idea to blog about it! It's called "ProCoder Encoder". What it does, is that it allows you to communicate with others using messages encoded with a key that only you and the people you are communicating with know. It is very simple and easy to use, and also it is free! If you are interested, you can download it here. It only works on Windows. Make sure to read the "README" file first... I'm also now hosting any updates on the project on a different tab on this blog! Have a nice day!

P.S.: If running the program gives you errors, try deleting it and downloading it again.

Sunday, May 26, 2013

Urgh, finals!

Hey! I know I've been inactive for quite some time, and I want to apologize for that. The thing is, I'm going through finals currently, and it's kinda difficult to find the time to work on the blog, on my channel or on my game(s). But do not worry! Soon I will be back with lots of new stuff, like recordings, stuff about Python and more. Stay tuned!

Monday, May 13, 2013

Return Of The Dead - RotD Update #1

Heyyyy!!! How's it going? So, quite some time ago, I started developing an FPS game in Flash, and it...hasn't made much progress. And that's because its creation was poorly timed with my everyday schedule. But let me tell you the whole story.

The whole idea to make this game came from a "test project" I had done in Flash, which was finished around November of 2012 from what I can recall. I wanted to make an FPS, but I had tried again back in 2011 and failed miserably because of the lack of knowledge (especially in programming). So, having tried many other programming languages, around late December of 2012 I thought of building upon this "fps test" file, and that was the birth of "Return of the Dead". I decided to make a game with zombies because that made the game production a lot easier in many ways, and that decision was quite wise, if you consider the people working on the project (it's only me, lol).

Unfortunately, I stopped working on the game around January of 2013, because my vacation ended, and with the school work and all being at least two times harder than last year (that's quite normal actually lol) I made my last additions to the game and then stopped completely working on it.

So, with my easter vacation the last two or three weeks, I had some time to add stuff. The only thing that gets in the middle now are my finals. Theoretically, I have the whole summer to work on the game. I say theoretically, because my finals end in 14th of June, and three weeks of July will be lost because of school summer classes which, unfortunately, are mandatory and of great importance for next year. The other thing is my band; we will possibly be working on our own songs. Finally, there is my channel, to which I came back actually in December 2012, and I don't want to leave it again for a long time.

With these being said, let me give you an update: The basics, meaning the gun, the HUD, the controls and everything, are ready. The menu is also almost ready, I just need to finish a couple of things, which are minor additions and stuff like that. The part of the game I haven't worked on contains picking up items, which I have not tried before and therefore I'm not sure if it will work the way I have in mind to make it, and this is mostly about programming. The last thing I have to do is make sure that the navigation system works, but I think this will be very easy, since I have done it in the past and I know it works.

So, thanks for reading! I also keep an update log, which I'm currently thinking about releasing, but for now, here's the logo of the game and a picture of the main menu:





Wednesday, May 8, 2013

How To Create A Class In Objective C (Xcode)

How To Create A Class In Objective C (Xcode)



Note 1: Every bit of code that is red means that it's the new code that's been added since last time.

Note 2: Everything mentioned here will only work in a Command Line Tool - Foundation project type.


So, let's begin by importing the Foundation file. This is just a bunch of code required for any Objective C program to run, so instead of writing it down each time we can just load the file that contains it:

#import <Foundation/Foundation.h>

Then, it's time to make the interface!

At first, let's name the class and write the variables:

#import <Foundation/Foundation.h>

@interface Person: NSObject{ int age; int weight; }

As you can see, we're making a class called "Person", and the only variables that we need are the person's age and weight.


Now let's go ahead and make the methods (aka what a "Person" can do, like "brush your teeth" or "eat" etc. - we'll keep it real simple though):

#import <Foundation/Foundation.h>

@interface Person: NSObject{
 int age;
 int weight;
}
-(void) print; -(void) setAge: (int) a; -(void) setWeight: (int) w; @end

Since the interface is done, we can go ahead and make the implementation!

Firstly, we need to write the "print" method, which just takes the values of the "age" and "weight" variables and prints them on the screen:

#import <Foundation/Foundation.h>

@interface Person: NSObject{
 int age;
 int weight;
}
-(void) print;
-(void) setAge: (int) a;
-(void) setWeight: (int) w;
@end

@implementation Person -(void) print{ NSLog(@"I am %i and weigh %i pounds", age, weight); }

Next, we need to do the same for the setAge and setWeight methods:

#import <Foundation/Foundation.h>

@interface Person: NSObject{
 int age;
 int weight;
}
-(void) print;
-(void) setAge: (int) a;
-(void) setWeight: (int) w;
@end

@implementation Person
-(void) print{
 NSLog(@"I am %i and weigh %i pounds", age, weight);
}
-(void) setAge: (int) a{ age=a; } -(void) setWeight: (int) w{ weight=w; } @end

What they do, is that they take what's into the temporary variables ("a" and "w") and store it into the main variables ("age", "weight").


Now, we finally start making the actual objects!

First, let's make the main method:

#import <Foundation/Foundation.h>

// interface
@interface Person: NSObject{
 int age;
 int weight;
}
-(void) print;
-(void) setAge: (int) a;
-(void) setWeight: (int) w;
@end

// implementation
@implementation Person
-(void) print{
 NSLog(@"I am %i and weigh %i pounds", age, weight);
}
-(void) setAge: (int) a{
 age=a;
}
-(void) setWeight: (int) w{
 weight=w;
}
@end

int main(int argc, char *agrV[]){ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init]; }

Now, the object code:

#import <Foundation/Foundation.h>

// interface
@interface Person: NSObject{
 int age;
 int weight;
}
-(void) print;
-(void) setAge: (int) a;
-(void) setWeight: (int) w;
@end

// implementation
@implementation Person
-(void) print{
 NSLog(@"I am %i and weigh %i pounds", age, weight);
}
-(void) setAge: (int) a{
 age=a;
}
-(void) setWeight: (int) w{
 weight=w;
}
@end

// main program
int main(int argc, char *agrV[]){
 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
 
Person *nicolas; nicolas = [Person alloc]; nicolas = [nicolas init]; [nicolas setAge: 25]; [nicolas setWeight: 350]; [nicolas print]; [nicolas release]; [pool drain]; return 0;
}

So what we did here is: First, we declared the object. Then, we allocated (aka borrowed) some memory from the computer,and then we initialized it. Next, we used the "setAge" and the "setWeight" methods to get values for our original variables, and then we used the "print" method to, well, print the values, and then we released any memory that was held by our object. Last but not least, we drained our pool of memory and returned 0, which means that our program ended perfectly.

Now let's go ahead and add another object, but using a slightly different technique this time (which I highly suggest you should use):

#import <Foundation/Foundation.h>

// interface
@interface Person: NSObject{
 int age;
 int weight;
}
-(void) print;
-(void) setAge: (int) a;
-(void) setWeight: (int) w;
@end

// implementation
@implementation Person
-(void) print{
 NSLog(@"I am %i and weigh %i pounds", age, weight);
}
-(void) setAge: (int) a{
 age=a;
}
-(void) setWeight: (int) w{
 weight=w;
}
@end

// main program
int main(int argc, char *agrV[]){
 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
 Person *nicolas;
 
Person *james = [[Person alloc]init];
nicolas = [Person alloc]; nicolas = [nicolas init]; [nicolas setAge: 25]; [nicolas setWeight: 350]; [nicolas print]; [nicolas release];
[james setAge: 57]; [james setWeight: 310]; [james print]; [james release];
[pool drain]; return 0; }

So, now we want to add two more "getter methods". They are simply going to return the "age" and "weight" variables. This, though, allows us to access these vars, which makes it easier to print stuff out. Let's see:

#import <Foundation/Foundation.h>

// interface
@interface Person: NSObject{
 int age;
 int weight;
}
-(void) print;
-(void) setAge: (int) a;
-(void) setWeight: (int) w;
-(int) age;
-(int) weight;
@end

// implementation
@implementation Person
-(void) print{
 NSLog(@"I am %i and weigh %i pounds", age, weight);
}
-(void) setAge: (int) a{
 age=a;
}
-(void) setWeight: (int) w{
 weight=w;
}
-(int) age{
 return age;
}
-(int) weight{
 return weight;
}
@end

// main program
int main(int argc, char *agrV[]){
 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
 
Person *james = [[Person alloc]init]; [james setAge: 57]; [james setWeight: 310]; NSLog(@"James is %i years old and weighs %i pounds", [james age], [james weight]);
[pool drain]; return 0; }

And that's how to create a Class!

Saturday, May 4, 2013

Python: Fahrenheit - Celsius Converter Tutorial

Python: Fahrenheit - Celsius Converter Tutorial


Introduction

Hello everybody, this is jimkokko5 on another tutorial. This time, we're talking about how to make a Fahrenheit - Celsius Converter in Python. I was, let's say, inspired to do this by the guys who teach me Interactive Python over at Coursera.org. It involves little knowledge of Python; it's real easy to make. Let's get started!


Getting Started

The first thing we need to do is to find the formulas needed to convert degrees in Fahrenheit to degrees in Celsius and vice versa. The next thing we need to do is to declare some global variables; we will need them later on.

# c = 5 / 9 * (f-32)
# f = 9 / 5 * c + 32

# define global variables
x = 0
y = 0

Making The Initialization Function

Next, what we need to do is set up our initialization function. This function simply displays text, and we need it to run immediately when the program starts.

# initialization function
def init():
    print "==========================================="
    print "Celsius - Fahrenheit Converter, v1.0"
    print "~Made by jimkokko5~"
    print "==========================================="
    print ""

Defining The Event Handlers

What we need to do now is to define our event handlers. These will run when the user enters a value, for example degrees in Celsius to be converted to degrees in Fahrenheit. The first one converts degrees Fahrenheit to degrees in Celsius, and the second one does the opposite.

# define event handlers
def f2c(f):
    f = float(f)
    c = 5 / 9  * (f-32)
    print f, "degrees Fahrenheit is", c, "degrees Celsius"
    print ""
 
def c2f(c):
    c = float(c)
    f = 9 / 5  * c + 32
    print c, "degrees Celsius is", f, "degrees Fahrenheit"
    print ""

As you can see, we take the string the user has entered, we convert it into a float (something close enough to a rational number) and we use the formulas we found earlier to convert it to the opposite value (if it's Celsius convert it to Fahrenheit and vice versa). Finally, we print the results.


Registering The Event Handlers

Last but not least, we need to register our event handlers, aka getting everything to run. This is real easy to do; we will also use our "x" and "y" global variables to hold the input.

# register event handlers
init()

x = input("Convert Fahrenheit to Celsius: ")
y = input("Convert Celsius to Fahrenheit: ")

f2c(x)
c2f(y)

And that's it. Our program is now ready to run!


Full Code

# c = 5 / 9 * (f-32)
# f = 9 / 5 * c + 32

# define global variables
x = 0
y = 0

# initialization function
def init():
    print "==========================================="
    print "Celsius - Fahrenheit Converter, v1.0"
    print "~Made by jimkokko5~"
    print "==========================================="
    print ""
 
# define event handlers
def f2c(f):
    f = float(f)
    c = 5 / 9  * (f-32)
    print f, "degrees Fahrenheit is", c, "degrees Celsius"
    print ""
 
def c2f(c):
    c = float(c)
    f = 9 / 5  * c + 32
    print c, "degrees Celsius is", f, "degrees Fahrenheit"
    print ""
 
# register event handlers
init()

x = input("Convert Fahrenheit to Celsius: ")
y = input("Convert Celsius to Fahrenheit: ")

f2c(x)
c2f(y)

Full Code (Python 3.0)

# c = 5 / 9 * (f-32)
# f = 9 / 5 * c + 32

# define global variables
x = 0
y = 0

# initialization function
def init():
    print ("===========================================")
    print ("Celsius - Fahrenheit Converter, v1.0")
    print ("~Made by jimkokko5~")
    print ("===========================================")
    print ("")
 
# define event handlers
def f2c(f):
    f = float(f)
    c = 5 / 9  * (f-32)
    print (f, "degrees Fahrenheit is", c, "degrees Celsius")
    print ("")
 
def c2f(c):
    c = float(c)
    f = 9 / 5  * c + 32
    print (c, "degrees Celsius is", f, "degrees Fahrenheit")
    print ("")
 
# register event handlers
init()

x = input("Convert Fahrenheit to Celsius: ")
y = input("Convert Celsius to Fahrenheit: ")

f2c(x)
c2f(y)

Thursday, May 2, 2013

New track recording!

A couple of days ago, Stranger, me and some other guys, recorded our first track. It took me a lot of time to mix and master it, and it was recorded in my house, which means that we didn't have the best equipement or instruments there are. It turned out pretty well though, and we will make a video and upload it to YouTube sometime soon. Here's a screenshot:


Sunday, April 28, 2013

YouTube bugs...

I'd like to talk about a couple of YouTube bugs I've spotted lately. They both have happened to me very often the last 2 weeks and they are REALLY annoying.

So, the first one is this: When you go fullscreen on a vid, it loads like, the 2/3 of the actual video, and you need to close the fullscreen, refresh the page and watch the video on normal screen. Why?!

The second one is this: When you're watching a video at 720p or 1080p, and you click in some "future" portion of the vid which hasn't been loaded yet, instead of putting your YouTube cursor there and load the video, it just throws the cursor back at the beginning, no matter how many times you do it. This has also failed to work after multiple refreshes.

Hello!

So, this is my first post on my official blog. Wee.
Anyway, I have uploaded (and currently uploading) my new Adobe Flash Tutorial series on how to make a sniper game in Flash (CS3 or greater). You can check these here:

Part 1:



Part 2:




Part 3:





Part 4: