Making videogames with pilas
|
|
In this article I want to tell you briefly something about game development, why I think it is an interesting idea for carrying to schools and how to implement it by making games easily.
Why make games?
Developing games is a really interesting activity, is to advance a project, give life to a idea, tell a story and put into practice a lot of useful concepts about computers, math, literature, physics, etc..
And they're addressed to an audience, because video games themselves are very striking, all people I tell about videogames love the idea, and are usually very excited sharing how to have fun or fun with this or that game.
For that reason, I think we can begin to see the entire game as something more than just fun. Because it is also a valuable opportunity to learn and stimulate interest of the kids in the classroom.
It's easier than it seems ...
But nearly always we talk about programming many people have to face many fears and preconceptions sometimes wrong. Some time ago making programs was a complex task, but is not so today.
Luckily, Python, along with high-level libraries and access to technology are giving people more and more tools to make creative and innovative things with their computers.
Pilas
Pilas is a library developed to facilitate game development at all ages.
It is aimed primarily at youngsters, who recently discovered computers and want to do something creative with them.
Creating a window and lot of actors
An example from the python interactive console : pilas is used as any module that we can incorporate and start using as follows:
import pilas pilas.iniciar()
The function iniciar is responsible for opening a window, and offers some optional arguments if we want to specify them (this is not the case.)
Once we have the window, we could create an animated character to have some action:
pelota = pilas.actores.Pelota()
What you see on screen is a bouncing volley ball alone on the floor. And if we want to bounce it against something else we could multiply it to have a lot bouncing balls:
pelotas = pelota * 10
And what about gravity?, you can change it easily as follows:
pilas.fisica.definir_gravedad(10, 30)
Where 10 and 30 are horizontal acceleration and vertical respectively. Indeed, the usual values are usually 0 and -90.
A more specific example
Consider this a little more in detail, write pilas.reiniciar() to clean up what we have in the screen.
Now, the actors are objects that live in the module pilas.actores. For example if we write:
mono = pilas.actores.Mono()
You will see a little monkey in the middle of the window, and because we created it using a reference we will be able to indicate things such as the following:
mono.gritar() mono.decir("Aguante la revista PET!!!")
We could also alter some visual properties like rotation, size, position, transparency etc. Take this example, let's move the monkey to the right of the screen and double its size:
mono.x = 100 mono.escala = 2
Did you notice that the changes are immediate? How do we create animations?. You just have to change the integer numbers by lists:
mono.x = [0] mono.y = [200, 0] mono.rotacion = [360]
The first sentence moves the monkey to the center of the window (horizontally), the second statement makes the monkey move up and then down. And the last sentence makes the monkey turns a full circle.
All actors are objects
The example above shows that the actors, are actually objects, have properties scale, x and y, but also have behavior, as the methods decir or the interpretation of messages as * (same as the numbers and strings) as we saw in the example of the volley ball.
This is a very powerful programming idea, because means that when you master one actor, in fact, you are learning to handle many actors, and in turn you are programming in python!
Researching
There is a function of pilas that comes useful when you start investigating: the function pilas.ver:
pilas.ver(mono)
This feature can be used to inspect the source code of anything: modules, functions, actors, object references to classes etc ... How does it work?, easy, issue a pilas.ver (pilas.ver).
And of course there is the function help and code auto-completion.
Even if you type pilas in a terminal, you'll notice an application that lets you see all the examples of code including pilas:
Looking ahead
I believe this is an interesting opportunity to show what fun and interesting programming is. A possibility of giving people a very powerful tool to move from consumers to producers of technology.
Just that at this point, it is not something purely technical, because the challenge is precisely disseminate, create and help inside of pyar to encourage people to participate.
For this reason, if you liked what you saw in this article, my advice is to encourage to write and tell more people about game development.
You could visit the website of pilas (www.pilasengine.com.ar), tell the pyar mailing list what you think or any ideas you have. Your comments are valuable for this and other projects can then move on.
Help PET: Donate
blog comments powered by Disqus