Navigation Menu

Blog

More posts »
Apr14

Collisions trouble.

Posted on Apr 14 by

About lately occurred collision problems. At first I was satisfied with a first solution for collisions resolving: checking collisions after one movement iteration. What is a movement iteration: a constant time during which objects change their position, normally by moving to the next tile. If an object has a different speed, than it moves at that time a different number of tiles. This ‘movement iteration’ concept gives me more control about game flow: one movement iteration, one positions change for every object. But lately more situations started coming up. So here are those situations with collisions check implementation explanation. First situation shows a variant which was mistakenly assumed to be the only one. Both objects end their movement on one tile. Both are reported to CollisionHandler: var GAME_POS = GAME_OBJECT.mov().gamePosTo; prepareArray(this.tilesToHandle, GAME_POS.x, GAME_POS.y); var ARR = this.tilesToHandle[GAME_POS.x][GAME_POS.y]; (...) var TILE = this.tilesManager.get(GAME_POS.x, GAME_POS.y); ARR.push(TILE); And later every tile is used to make an every to every collision test. Second situation shows that collisions can occur during movement iteration: when objects are passing each other during normal movement or when...

Apr10

RunPigsRun: about the progress.

Posted on Apr 10 by

A little report on a progress. I had some issues with collisions, as it turned out, I haven’t taken into account collisions between objects passing each other. Previously, collisions were only checked, when objects were ending their movement on a tile. It’s a game’s clock: one movement iteration (movement from one tile to another, also with a different speed). When I have introduced Enemy objects (objects killing Heroes) it turned out, that there is no collision detection between objects passing each other… Collisions where checked when all objects finished their movement on a target tile. I’ve fixed that lately and now collisions events are distinguished on: those fired, whenever collision between objects occur and on those fired, when both objects end their movement on the same tile. Maybe next time I’ll explain the reason behind this concept. I have made code easier by introducing ‘void’ type fields, to check collisions for objects which bounces off outside the road. In this way empty fields are also participating in collision tests. The next thing is choosing tools by a player. The...

Apr04

Thoughts flow. Inner monologue.

Posted on Apr 4 by

Introduction This post is related to Dajsiepoznac16 contest in the same way as every IT project/design process/task I was participating in. Whenever any process, which requires planning, is started, I open a text editor and start taking notes. I need this to organize thoughts, ideas, plans, concepts. Storing ideas For every project I have a separate file, where everything which comes to mind can be stored. I don’t believe in storing ideas in a head: memory can’t be trusted in this one. Besides: notes can be organized, tagged… and reviewed without a doubt, that something is missing. Notepad is a trusted place. Write down and forget. Your thoughts will remain here. Head is not the best place to store ideas. What has to be done? If I start e.g. a new feature, I’m trying to answer a “what has to be done right now?” question. Every problem, no matter how big, can be divided into concrete steps. In this way, I’m not working on a project: I’m working on a concrete problem, which has clear ‘it’s done’ definition. And...

Mar25

RunPigsRun: handling collisions.

Posted on Mar 25 by

Collisions in RunPigsRun One of the things that gives me some confidence about finishing this project is the form of its gameplay. Objects are moved from field to field in a predictable way. Collisions are checked after all the objects finish their movement, which simplifies the work. Which collisions are already handled? Hero + Bouncer changes object’s speed plays scaling animation for the bouncer Hero + Void field; Hero + Water field removes hero from the game reports game’s loss plays field’s scale animation Hero + Exit removes hero from the game reports that hero was saved How it’s implemented I really like Javascript’s duck typing. Earlier Mr. Czocher reported in comments, that I should checkout Typescript, which (I assume from the introduction videos) will make code more standardized e.g. by interfaces. I’m really curious if it will not lower the speed of coding, as with my current code organization I’m having a really small amount of bugs and generally work goes smooth. That was just a small digression. What I want to say, that with Javascript’s conventions I’ve...

Mar23

Tiled Editor: composing levels.

Posted on Mar 23 by

What is it? Phaser framework supports loading data about the maps from a couple of formats. As RunPigsRun is not a complicated game with levels built from tiles, Tiled map editor is a sufficient choice. How does it work? First an image presenting a tileset is needed, I’ve got mine from here: http://opengameart.org/content/tiny-16-basic (by: http://opengameart.org/users/sharm). As I’ve mentioned earlier: don’t care how the set looks (although it’s nice). After importing image to program, three types of layers from which level can be built are available: Background Layer. Tiles on this layer are intended to be used as a background: in the game they will be only displayed. Even putting them in editor reminds drawing with a brush. Object Layer. Used to create concrete objects represented by a tile image. Such objects can be translated/rotated. They are named and put into an objects tree. In contrary to Background Layer, created objects are exported with information like: position, id of a tile in a tileset or custom properties (properties set by us). Image Layer. Don’t know, never used it. Probably used...

Mar15

RunPigsRun: the code organization.

Posted on Mar 15 by

As this is my second project in Javascript, I’ve manage to achieve code organization/conventions, which helps me to move through code quickly and make it less error prone. I was mainly inspired by some games from https://github.com/photonstorm/phaser-examples. There will be nothing revolutionary nor even advanced here. Classes I’m a fanatic of decomposing code into classes, every time, everywhere. Class should be concrete, specialized, well named and decomposed into specialized functions. If class is getting big, part of its functionality should be extracted into another classes. Everything above is crystal clear, yet generally JS is strangely considered as a language, where everything should be accessible from everywhere, and code is just one big sequence of monstrous functions which are so, so, so… SO hard to read. Sometimes it’s even impossible to track paired brackets. Anyway: readability first… as the famous quoute says: Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Generally I’m organizing code into directories to simulate something like packages… Next: I’m writing quite a...

Mar13

Beeminder: a healthy sting.

Posted on Mar 13 by

Previously described Rescuetime is doing almost a perfect job. You can track Your daily productivity and weekly goals (remember how You can create ‘Software Development’ objective?). But what if You fail to achieve Your personal vow, to work on a software project X hours a week? Ha! Nothing! Maybe You feel a little bad, that’s all. I’ve heard that in one office, when someone had sworn, he had to put some cash in a jar. It’s the same like saying to someone ‘punch me, if I ever do X again’. Or when You make an agreement with someone, to not to come back to a bad habit (smoking maybe?) as long as he/she does something similar, which is important to You, in return. A public agreement… someone is watching You, so it’s harder to break the rules! How about something guarding our goal to spend X hours a week on a software development? Let me introduce You to … … “A kick in the pants!” Beeminder is a service allowing to create weekly goals on doing anything quantifiable. Users...

Mar06

Rescuetime. To the rescue.

Posted on Mar 6 by

I would like to share some informations about one of the tools I’m using to keep the track of my progress on my ‘Run Pigs Run’ project. As an introdcution: I think that this description of some ‘productive’ evenings can sound very familiar to many of us. The story. You’re reserving the whole evening to work on something. On Your hobby project (‘Dajsiepoznac’ project, maybe?), on Your homework etc. You’ve already refused Your friends to go out, because ‘sorry, I’ve got work to do’. And You start. Editor started, music playlist chosen, coffee ready… You’re really pumped up, this will be a productive evening. Start. It’s going pretty well, until the first problems occur. You’re suddenly not so very enthusiastic and it’s not a nice feeling: it appears that You have to do some extra work to push Your progress further. Maybe extra research is needed, maybe using new programming tool requires to read some documentation, maybe a bug appeared and You even have no idea how to start to fix it. So to forget about all that, You’re...

Mar03

Dajsiepoznac: about the project.

Posted on Mar 3 by

The reason I’ve started ‘RunPigsRun’ (probably temporary title) about two months ago, I’m developing it quite regularly. But: a lot work ahead. https://github.com/adamskopl/runpigsrun Project is written in Javascript, the language I’m still learning (I’ve learnt the basics from here http://eloquentjavascript.net/). I’m using the Phaser framework. I’ve finished one project in this framework, it’s available here: http://skobo.pl/safedrive. My aim is to: write a not so complicated game it has to be entertaining it has to look nice (I’ll have i big help at this point) it has to be finished entirely The rules The gameplay will take place on the levels composed from tiles (10×10). Level is occupied by pigs, wolves, roads, obstacles, traps and other objects. Player can start the game and observe its course. Pigs start to run (hence the game’s title: clever, eh??), wolves start to chase them and so on. Without the intervention, pigs end their existence by drowning/ being caught by wolves/and maybe by other, more spectacular ways. The player’s task is to use available tools and rescue all the pigs by helping them leaving...

Mar02

Hello Dajsiepoznac.

Posted on Mar 2 by

Recently I’ve sent my project “Run Pigs Run” as an entry for polish “Daj Się Poznać” (“Get Yourself To Know”) contest, organized by Maciek Aniserowicz. It has already over 200 registered projects. Long story short: as a participator I have to: work regularly on my project for about three months, counting from the beginning of march write at least two posts weekly about progress/thoughts/programming quirks connected with my work on a project I’m very thrilled about the idea, hope to stick to the plan. written in Emacs with org2blog...

Jan27

Hello reference.

Posted on Jan 27 by

Switching daily from C++ (day work) to JS (hobby project) results in happily careless programming. I’m so thrilled with duck typing, that in some functions it’s seems to be obvious, that passed object argument is a reference and yet, when I’m writing function using a reference only to check something, sometimes I’m forgetting that I’m performing an operation on a “living being”: TilesManager.prototype.getAdjacent = function(gamePos, direction) { switch (direction) { case MovementDirections.U: gamePos[1]--; break; case MovementDirections.R: gamePos[0]++; break; case MovementDirections.D: gamePos[1]++; break; case MovementDirections.L: gamePos[0]--; break; } return this.get(gamePos[0], gamePos[1]); } gamePos modified outside. A moment ago function was receiving two numbers (not objects) posX, posY and everything was a-ok (pass by value). Ok, “let’s make gamePos uppercase (ergo suggest DON’T F TOUCH THIS), make a copy at the beginning and use it instead: TilesManager.prototype.getAdjacent = function(GAME_POS, direction) { gamePos = GAME_POS; switch (direction) { case MovementDirections.U: gamePos[1]--; break; No. Still having a reference: the gamePos IS the GAME_POS. So let’s make a copy. Stackoverflow to the rescue. http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-an-object http://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object (poor Stackoverflow crew: reminding on every step to not...

May25

SafeDrive project

Posted on May 25 by

A project written in Javascript with a Phaser framework (http://http://phaser.io/). A presentation is showing dangerous/illegal traffic situation according to the Polish traffic law. Project is published here: http://skobo.pl/safedrive Source code: https://github.com/adamskopl/safeDrive All graphics by Anna Skobodzińska (http://anna.skobo.pl, anna@skobo.pl). Nothing more to add : ). Just start clicking. (it’s best to test it here):...

Jan05

Cubicforest: progress report and gameplay rules.

Posted on Jan 5 by

A little report on my work on Cubicforest. Unfortunately from the beginning of October my life was completely upside down to the end of December and I couldn’t find time and energy for continuing the project. But I will start new commits soon. Last time I was working on levels resolver. Being surprised by the number of combinations of the possible game courses, I’ve realized, that a class solving levels is necessary. Let’s say we have a simple level: The rules of Cubicforest are as follows: Player is moving to any accessible tile, having 3 points of movement. Player can end its movement with building an item. After player the enemy’s movement is taking place (3 points of movement also). It’s AI is simple to pain: every enemy, one after one, is moving to end on a tile nearest to the nearest hero. Player loses if enemy ends its movement on a Player’s tile and wins if every Player’s character has ended movement on a Portal item (which has to be built by a player). Getting back to the...

Jan02

Buildings editor

Posted on Jan 2 by

Project from 2011 written as a Bachelor thesis. Project’s goal was to create program allowing to quickly define 3d urban spaces and to explore them in a Java applet (it was a second program called CityCube allowing to move user’s avatar through the building). Buildings data is created by defining floor sectors, which can be enriched with walls, windows and connected with stairs or doors. Data can be exported to XML and loaded by CityCube, where is rendered. Building’s structure allows to explore created space in a logical way, by creating paths between any building’s sectors. E.g. user’s avatar can look up for a specific room and program will calculate the shortest path by connecting nodes, which lays on every sector’s border and on edges of the doors and stairs. In this way avatar can travel through created path. Program’s mascot is a little pig engineer: Video presenting designing process (should be wathced with 720p...

Dec23

Back in time: old OpenGL project

Posted on Dec 23 by

Old OpenGL project from 2010 using my MD2 model exported from Blender. I was really happy from the ‘chasing’ camera’s...

Dec23

Tangbang

Posted on Dec 23 by

Project from 2010 written for educational purposes. Code was used to present basics of games programming during classes of an academic circle about programming games on a Białystok Technical University. Covered topics: generating OpenGL graphics; using SDL for input, window system and sound; collisions detection; simple AI....

Dec20

Recording application video with sound: Alsa + Recordmydesktop

Posted on Dec 20 by

How to capture video from an application with the sound? Don’t know if it’s by default, but in my Xubuntu, only a sound from the microphone can be recorded. This link came with help: https://trac.ffmpeg.org/wiki/Capture/ALSA. How to do the same with a recordmydesktop application: Create .asoundrc file in Your home directory like in mentioned webpage: # .asoundrc # uncomment to record audio from applications. uncomment afterwards to # restore default Alsa settings: # pcm.!default { type plug slave.pcm "hw:Loopback,0,0" } When the last line is uncommented, there will be no sound for every application launched from that moment, because generally it’s redirected to the recording output. Load the snd_aloop module: modprobe snd-aloop pcm_substreams=1 Launch an application, from which the video will be captured. Check it’s window id with xwinfo and by pointing application’s window: xwininfo | grep 'id:' Invoke recordmydesktop with hw:Loopback,1,0 as a sound device. PID will be needed to send signal to stop recording (‘& echo$!’) recordmydesktop --windowid [application wid] --device hw:Loopback,1,0 --v_quality 45 --s_quality 7 --overwrite & echo $! Stop recording by sending SIGTERM signal: kill...

May21

Cubicforest: using Tiled

Posted on May 21 by

In a second post I was writting about creating my own level editor. A lot has happended since then (thank You reality, You’re a perfect teacher): games is being written in Java using http://libgdx.badlogicgames.com/ right now and for editing levels I’m using Tiled editor http://www.mapeditor.org/. I’m very happy from that solution. Level is exported to Json. Loading done with gson https://sites.google.com/site/gson/gson-user-guide. Just a few classes reflecting Json’s file structure and I was ready to go… public class TiledMap { private Integer width; private Integer height; private Integer tileheight; private Integer tilewidth; private List<TiledLayer> layers; ... public class TiledLayer { private String name; private Integer height; List<TiledObject> objects; ... public class TiledObject { private Integer gid; private String name; private String type; private Integer x; private Integer y; What’s interesting: loading is done with one line! public class MapsLoader { TiledMap tiledMap; ... tiledMap = new Gson().fromJson(mapFileString, TiledMap.class); … and TiledMap class is filled with a data about designed level Project’s repository: https://github.com/adamskopl/cubicforest-java. Tiled editor: Level loaded in a...

May11

Mass e-mails: avoid being marked as a spam.

Posted on May 11 by

For four months now I’m volunteering my time at Uniwersytet Dzieci organization (a child university). Amongs the others I’m helping in running lessons about the Blender software. Lessons are crowned with a show, where students can present their new skills. After organizing students mailing list I’ve encountered some problems. The problem I’ve gathered more than 40 emails to write to students about their roles in the show. I’ve created a couple of mailing lists, e.g. the list including all of the students. First mail was composed by adding this list as BCC to make addresses private. On the last lesson I’ve realized, that Gmail users had not received my mail, while students with addresses from other domains did. The reason is unknown, but I’ve searched the web and have found some clues: filters can reject mails, where receiver is in BCC filters can reject mails if there is a big number of receivers filters can reject mails if the server had received a big amount of messages from one address in a short period of time I’m not completely...

Oct13

Cubicforest: built-in editor

Posted on Oct 13 by

I had a lot of thinking about editing levels. Wanting to keep them simple, I’ve chosen good old square tiles solution. First I was convinced, that I’ll save a lot of work by choosing ready editor (like this one: http://www.mapeditor.org/), but after doing some calculations, I’ve decided to make my own. Main reasons: Most part of editor’s code will be used in game play code: functionality of those two is very similar. Switching between game play and editor will be nice (smooth levels testing). It seems that time spent on adjusting design solutions to someone’s editor is similar to time spent on building my own (especially, that game levels will not be sophisticated). Well, reality will verify that. Time to dive into stream of concrete design thoughts about first version of game editor. Building a level Cubic Objects Every object occuring in a game’s world, will be composed from little cubes called AtomicCubes. Format of models representing those objects will be discussed another time. Composing terrain. For now I’m assuming, that terrain will be built from Fields composing a...