Tag: programming

Linked Lists in Lua

Posted on November 16, 2012 in Tutorials

As an example of creating custom data structures in Lua, I thought I'd give a little demonstration of a linked lists implementation. Note that this isn't going to be an in-depth tutorial or anything; for the most part I'll just be showing pieces of the code. Linked lists are wonderful data structures, perfect if you need to efficiently add, remove, and iterate through elements. The one trade off is that you can't find an element...

Read more...

Ammo

Posted on October 15, 2012 in Projects

This announcement post is a bit overdue, but, better late than never. A short while ago, I released the first version (0.1) of Ammo, my organisational library for LÖVE. Its current version is 0.1.3. I plan to let the library stay in the 0.x range for a while as it's tested by me and any others who use it. Along with the core library, there's a number of extensions available. The one I'm most excited...

Read more...

Custom Cursors in Love2D

Posted on September 20, 2012 in Tutorials

When making a game in LÖVE, you'll probably end up needing to customise the mouse cursor. As I recently had to do just that, I thought I'd make a quick tutorial on it. If you want an example cursor, here's the crosshair I'm using in a game right now. Now, all of what we need is contained within the love.mouse module. The first step is to hide the mouse with love.mouse.setVisible. You'll probably want to...

Read more...

Lua for Programmers Part 4: Tips and Tricks

Posted on September 09, 2012 in Tutorials

If you haven't read the previous parts (one, two and three), then I'd highly recommend doing so. For reference, here's a list of the parts in this series: Part 1: Language Essentials, covers fundamental syntax and concepts such as operators, loops, and functions. Part 2: Data and Standard Libraries, covers Lua's built-in data types and some of the standard libraries. Part 3: More Advanced Concepts, deals with things like variable scope, advanced functions, and file...

Read more...

Lua for Programmers Part 3: More Advanced Concepts

Posted on September 07, 2012 in Tutorials

If you haven't read part one and two already, I'd highly recommend doing so. For reference, here's a list of the parts in this series: Part 1: Language Essentials, covers fundamental syntax and concepts such as operators, loops, and functions. Part 2: Data and Standard Libraries, covers Lua's built-in data types and some of the standard libraries. Part 3: More Advanced Concepts, the current part; deals with things like variable scope, advanced functions, and file...

Read more...

Lua for Programmers Part 2: Data and Standard Libraries

Posted on August 27, 2012 in Tutorials

If you haven't read part one already, I'd highly recommend doing so. For reference, here's a list of the parts in this series: Part 1: Language Essentials, covers fundamental syntax and concepts such as operators, loops, and functions. Part 2: Data and Standard Libraries, the current part; covers Lua's built-in data types and some of the standard libraries. Part 3: More Advanced Concepts, deals with things like variable scope, advanced functions, and file loading. Part...

Read more...

Lua for Programmers Part 1: Language Essentials

Posted on August 27, 2012 in Tutorials

In this series we'll be taking a look at most everything you should know to program in Lua. The series is targeted at people who already know how to program, and as such I'll aim to be brief in my explanations. Here's an overview of the four parts the compose the series: Part 1: Language Essentials, the current part; covers fundamental syntax and concepts such as operators, loops, and functions. Part 2: Data and Standard...

Read more...

Rock 'n' Slash: Ludum Dare 23 Postmortem

Posted on April 29, 2012 in Projects

Well, I think it's about time I made my Ludum Dare 23 postmortem. First of all, I blame not posting in a long time on my seemingly inherent laziness. Procrastination is an easy trap for me it seems, but that's another topic altogether. Back on subject, the latest Ludum Dare took place between April 21st and 24th, with the main competition ending on the 23rd. It just so happens that this event was Ludum Dare's...

Read more...

Another Update on Illusive Dreams

Posted on November 12, 2011 in Projects

It's about time for another update post on my platformer, Illusive Dreams. As you may guess, I've finally found a name for the game. The main thing I've been working on is the levels for the game, with the first seven already done and two others which I'll use later on. I don't think I'll be making a hell environment, as it seems to be too much work right now (this is a free game...

Read more...

Pixel Says: A Game with One Pixel

Posted on October 30, 2011 in Projects

A couple days ago I felt like doing a quick game for a little change from the game I've been working on for the last seven weeks. For some reason, I decided that limiting myself to only one pixel would be a cool idea. So last night, in an hour and a half, using FlashPunk, I put together a Simon Says remake called Pixel Says. Obviously, the only thing that I wasn't able to do...

Read more...

Progress on the Platformer

Posted on October 28, 2011 in Projects

Since last time I posted on my new platformer game, a lot as happened (as you would expect). Since then, I've released two new progress videos, so instead of me throwing a wall of text at you, I'll let them speak for themselves. Take note that, like last time, the videos are darker than the game itself (though the severity of this seems to have improved somewhat). Here's the latest one: And the one before...

Read more...

How It Works: The Thruster in Facilitated Escape

Posted on October 23, 2011 in Tutorials

In this post I'll be taking a look at how I programmed aspects of the ship's thruster in my game, Facilitated Escape. I'll most likely be making more posts like this in the future (as in, I intend to make a series of "How It Works" posts). Initially I had a lot of trouble getting the thruster to look right; you might be able to see some of my troubles in the Ludum Dare time-lapse....

Read more...

A New Game and Future Plans

Posted on October 06, 2011 in Projects

I've been working on a number of things lately (hence why I haven't posted for a month), one of those things being a new game, which I'll be talking about in this post. After completing Facilitated Escape, I spent a few days wondering what game I should create next. This is where I've got with my idea so far: As a warning, YouTube has darkened the video a great deal, the game is actually lighter....

Read more...

Mouse Dragging in Love2D

Posted on September 06, 2011 in Tutorials

In this tutorial, I'll be taking you through my method of enabling objects to dragged by the mouse (in LÖVE of course). You can view the completed code for this tutorial at gist #1196228. So, say you have an object with x/y coordinates, width, and height, and you want this object to be draggable by the mouse. For this tutorial, I'm just going to construct a table and put in the global, rect: function love.load()...

Read more...

Ludum Dare 21

Posted on August 22, 2011 in General

After my complete failure in the last Ludum Dare, I didn't plan to take part in the next one (the 21st), however I decided to give it another shot. I'd learnt a number of things from my failure last time: go with a concept that's really simple, and use simple art, like pixel art, at least if you're a programmer like me. I also decided not use my personal framework for LÖVE; the biggest reason...

Read more...

Glow Effect for Lined Shapes in Love2D

Posted on July 16, 2011 in Tutorials

Recently I experimented with an easy way to make lined shapes glow (using LÖVE of course). There are of course other ways of doing it, and there are many styles of glow that can be used, but this is the one I came up with. love.graphics.setColor(r, g, b, 15) for i = 7, 2, -1 do if i == 2 then i = 1 love.graphics.setColor(r, g, b, 255) end love.graphics.setLineWidth(i) -- draw lined shape here...

Read more...

Lua Metatables Tutorial

Posted on June 30, 2011 in Tutorials

In this tutorial I'll be covering a very important concept in Lua: metatables. Knowledge of how to use metatables will allow you to be much more powerful in your use of Lua. Every table can have a metatable attached to it. A metatable is a table which, with some certain keys set, can change the behaviour of the table it's attached to. Let's see an example. t = {} -- our normal table mt =...

Read more...

A Guide to Getting Started with Love2D

Posted on June 14, 2011 in Tutorials

In this post, I'll attempt to give you my personal guide on some good steps to getting started with the Love2D game engine (the proper name is LÖVE, which I'll be using from now on). It's not perfect, of course, but I hope you find it useful. If you have any feedback, I'd love to hear from you in the comments. What is LÖVE? I'm guessing you probably already know, but for those who don't,...

Read more...

The Inconsistencies of PHP

Posted on June 12, 2011 in General

Over the past few months I've come to love the Ruby programming language for many reasons. After using this language for a while and having a blast of a time, when I came back to PHP, I found it disgusting. I used to love the language; my tastes of syntax have definitely changed, but one thing that really bugged me as I examined PHP closer, is its inconsistencies. As you can tell by the title,...

Read more...

ASCII Code Manipulation

Posted on May 12, 2011 in Tutorials

While inspecting the ASCII table a little while ago, I noticed some interesting patterns in it, which can be used for string manipulation. It's important to understand the ASCII table, because it's the base of most encodings. Note I'll be using C-like syntax in my examples, but I won't be taking advantage of C's characters, which convert stuff like 'a' into 97 (a's ASCII code). An Introduction For those who don't know what much about...

Read more...

Strong 1.0.2

Posted on May 10, 2011 in Projects

This morning I released strong 1.0.2, which adds three new methods to the mix: camelize, center, and underscore. center is the complement to ljust and rjust, and the others are from Rails' extensions to Ruby's String class. Take note, they aren't yet documented in the function reference. Anyway, go and grab 1.0.2 at its repo. Enjoy!

Read more...

Cameras in Love2D Part 3: Movement Bounds

Posted on May 09, 2011 in Tutorials

Because there was some interest in a part 3, of this series, I've written it, and in this part we'll cover creating bounds that the camera can't move beyond. Make sure you've read part 1 and part 2 before continuing. In case you're wondering what I mean by this, I mean restricting the movement of the camera to a "box", as in, having minimum and maximum x/y coordinates for the camera. This comes in handy...

Read more...

Draw Origins in Love2D

Posted on May 06, 2011 in Tutorials

In this post I'm going to be showing you origins when drawing stuff in Love2D. First of all, what are origins? They specify the offset for the origin of the object's x/y coordinates. In other words, if you specify the x origin to be 20, the object will be drawn 20 pixels to the left, as in x - 20. It's the same for the y origin: if we have a y origin of 20,...

Read more...

Ludum Dare 20: My Experience

Posted on May 02, 2011 in General

From April 29 to May 2 Ludum Dare 20 has been going on. For those who don't know, the main competition involves making a game based on a certain theme in a 48 period; tough call. Hundreds of developers have a shot at this every four months, and I thought I'd give it a try. In this post, I'm going to write about my experience in it, and the lessons I learnt. I'll let you...

Read more...

Strong: Make Your Strings Stronger in Lua

Posted on April 29, 2011 in Projects

For the last few days I've been working on a library called "strong". It's a string enhancement library for Lua. Strong adds a few operators to strings, and many methods to Lua's string library. I've already written more information in the README and the wiki, which you can go to for more information. Here's the direct link to the GitHub repo by the way. After much testing and refinements, I've just released version 1.0 of...

Read more...

Cameras in Love2D Part 2: Parallax Scrolling

Posted on April 22, 2011 in Tutorials

In part 1 we constructed a basic camera. Now we're going to extend it by adding some parallax scrolling. Note that the method I'll use is probably not the prettiest, as I came up with it in half an hour. Nevertheless, this will be a starting point for you to develop your own system. What Is It? Now, for those who don't know, what is parallax scrolling? It's a way to get a pseudo-3D effect...

Read more...

Cameras in Love2D Part 1: The Basics

Posted on April 19, 2011 in Tutorials

This is the first of a couple of blogs on creating cameras in the LÖVE engine. This part will deal with the fundamentals of creating a camera. Part two will deal with parallax scrolling and creating layers. So, let's get to it! Update: I've actually ended up writing a part 3, which covers restricting camera movement. The Functions The functions we'll need are these: love.graphics.pop love.graphics.push love.graphics.translate love.graphics.rotate love.graphics.scale Love2D (I'll use this name from...

Read more...

Specifying Names in Lua Without Strings

Posted on April 18, 2011 in Tutorials

Lua is the most flexible language I've ever used, aside from its speed, this is probably the best thing about it. In this post, I'm going to show you how to specify names of things in function arguments, without strings. The method I'll use it a bit hackish, and isn't fit for normal operation; but hey, Lua allows us do it! For an example, say you had an OOP implementation that used a function called...

Read more...

Launcher - Camera Improvements and Music

Posted on April 17, 2011 in Projects

A little late, posting this, but oh well. I've improved the camera by limiting where it can go, and also by added shakes on explosions. I've added some very quickly put together music. Lastly, I've experimented with increasing the velocity of wall explosions. Enjoy!

Read more...

5 Generic Rules for Clean Code

Posted on April 17, 2011 in General

I've been mulling over a few generic rules for a clean code style, and I though I'd share. These are very generic, as in, they don't give any specifics like two-space indentation or something. These rules are the things I've learned in my time coding, and they help me a lot to keep my code looking clean. Clean code is like proper English with good formatting, when compared with sloppy English. Sloppy English is faster...

Read more...

Launcher - Sound and An Awesome Level

Posted on April 14, 2011 in Projects

Now this gameplay video I'm pretty proud of. I've now added some very rough sound, generated with CFXR. This is also the first time I get to display a much more awesome level; because I'm telling you, it takes a lot of skill to play this kind of level with a screen recorder running, with all the jerkiness in framerate. The screen recorder also caused a few physics problems a long the way. At two...

Read more...

Launcher - Exploding Walls

Posted on April 13, 2011 in Projects

I just posted a new gameplay video of Launcher. Most of the time on Launcher since last time has been fixing bugs; there were some pretty serious ones in there. But anyway, that's over now, and the main new feature is exploding walls. Enjoy!

Read more...

Code for Launcher Released

Posted on April 11, 2011 in Projects

I thought I'd release the code for "Launcher" in its current state for the public to muck around with. Note that, as expressed in LICENSE.txt (make sure you read that), that this only applies to its current state. Meaning that you have this code under the terms of the BSD license, but don't have any future code under its terms. I know this is obvious, but hey, we live in a confusing, wacky, legal world....

Read more...

Launcher

Posted on April 10, 2011 in Projects

I've been working on a little game (in the LÖVE game engine), which for now I'm calling "Launcher". The core gameplay mechanic is this: you are a circle, which can stick to certain surfaces, and then launch yourself at great speed off them in the direction of the mouse. It's completely controlled by the mouse, you aim with it, and the distance between the player and the mouse determines the speed of launch. On my...

Read more...

Grace is No Longer in Development

Posted on April 08, 2011 in Projects

My big project called Grace is no longer under development. The reason I started this project, is because I wanted organisation to back me, before I started making a game. That wish is totally valid, but I went too far. Instead of sticking with some simple organisation, and only implementing what I actually needed, I made this monolithic framework that eventually became a little hard for even me to comprehend. After some examination, I found...

Read more...

Implementing Proper Getter/Setters in Lua

Posted on April 04, 2011 in Tutorials

When I create a class in Lua, there are always times when I need to use a getter or setter on attributes, instead of raw access. The way I've always done this is to use methods with names like getFoo and setFoo. And then to keep my API consistent, I have to switch every single property to use these getter/setter methods. The pain about these type of methods is that: You have to switch everything,...

Read more...

Some Uses for the Modulos Operator (%)

Posted on March 21, 2011 in Tutorials

I've been learning about a few of the awesome things you can do with the modulos operator lately. For those who don't know, the modulos operator (the percent symbol in code) gives the remainder of dividing two numbers. Therefore, 10 % 4 equals 2, because 4 goes into 10 two times, and what we have left is the number 2. Now let's get into what we can do (note, I'll be using Ruby code here,...

Read more...

Simulate Bitwise Shift Operators in Lua

Posted on March 21, 2011 in Tutorials

EDIT: Here's a couple functions which will do the shift operations that I've put in gist #938502. The fact that Lua doesn't have bitwise operators is a pain. There are pure Lua implementations out there, such as LuaBit, but I find these to be a little slow (I think LuaBit using tables or something like that). I've found a way to simulate both the left-shift and right-shift operator by using some simple mathematics. Left-Shift By...

Read more...

ClosureClass

Posted on March 13, 2011 in Projects

I've recently created an experimental Lua object-orientation library using the closure approach to OOP. It's based largely on MiddleClass, sharing a lot of design features with it. I've already written a README, so go and visit the GitHub repo for more information.

Read more...

MiddleClass Extensions

Posted on March 11, 2011 in Projects

I've just recently opened up a new repository at GitHub called middleclass-extensions, which contains my personal hacks, extensions, extras, whatever you want to call them, to MiddleClass. It's a bit like middleclass-extras. So far the repo only contains one extensions, called Static, but this will grow over time. Static is about creating class only methods. When you create a method which you intend to be accessed only via the class, MiddleClass has no way to...

Read more...

Mixin Inheritance in MiddleClass

Posted on March 09, 2011 in Tutorials

The technique I'm about to present, may seem obvious, but I'll share it anyway. The way I would create mixins that inherit stuff from other mixins is this: Mixin = {} function Mixin:included(class) if not includes(ParentMixin, class) then class:include(ParentMixin) end end When the mixin is included, it will check whether the class includes the mixin, and if not, it will include it, therefore simulating inheritance. It's good to check if the class includes the parent...

Read more...

Lua Performance Tests

Posted on March 08, 2011 in General

Just for some experimentation, I did some performance tests on a few operations in Lua. To time them I used the command, time lua test.lua, and took the "real" time. The test file was just a loop, which looped 20 million times: for i = 1, 20000000 do --[[ code here ]] end Alright, here's the results. Description Seconds Loop Code Variable/Function Definition Empty function call 1.249 f() function f() end Return function call 1.688...

Read more...

Singleton Class in MiddleClass (Lua)

Posted on March 07, 2011 in Tutorials

I thought I'd demonstrate a method for making a singleton class in MiddleClass. If you don't know, MiddleClass is an object-orientation library for Lua. So why would you want to make a class that only has one instance with MiddleClass? Couldn't you just use a table? Well, making it a class in MiddleClass allows you to take advantage of a number of other cool things that MiddleClass has on offer, like mixins, inheritance and so...

Read more...

Ruby - My Favorite Programming Language

Posted on February 24, 2011 in General

Ruby is my new favorite programming language. After about one or two weeks with it, I was sure this was my new favorite. Ruby is a wonderful language, with so many advantages, so I thought I'd write a blog post about it. Before I found Ruby, I was in a dilema about which programming language was my favorite. I had recently found Lua, and immediately loved syntax, but Lua is nowhere near powerful enough in...

Read more...