Character creation

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
crystalheartstudios
Prole
Posts: 10
Joined: Thu Sep 04, 2014 7:38 pm

Character creation

Post by crystalheartstudios »

Alright, so I am completely new to Love2D and I'm fresh off the boat from programs like gamemaker, unity3d, and udk. Most of those have prebuilt character controllers (minus GameMaker), therefore I have no idea how to start developing a character. I have a Legend of Zelda style tiled background set up, and I need to know how to start making the character that would go in.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Character creation

Post by Plu »

That's a little broad. But I'll give you a little boost.

For your character; the two key things you'll need to start with are making a table to store the character's data in along with some functions to modify it, and to build a simple system to translate keyboard commands to function calls on the character object. (Using, probably, love.keyboard.isDown or the love.keypressed event)

Then you'll need to add some function(s) that can draw the character to the screen, which you'll need to call in love.update.
User avatar
murks
Party member
Posts: 185
Joined: Tue Jun 03, 2014 4:18 pm

Re: Character creation

Post by murks »

Well, there's no such thing as a characte in Löver, you just code whatever you want from scratch. Here's the API deocumentation: https://www.love2d.org/wiki/love
There are couple of libraries the were built on top of the API that could help you safe time. Many libraries are listed here: https://www.love2d.org/wiki/Category:Libraries

Have fun coding ;)
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: Character creation

Post by rmcode »

The difference between löve and those other programs is, that it doesn't give any premade resources you could use, but it gives you the total freedom of doing everything the way you prefer to do.

Here is an example of a character template. It uses a closure approach to allow OOP (there are other approaches aswell - find one you like).

Code: Select all


local Char = {};

---
-- Creates a new char
--
function Char.new(name)
    local self = {};

    local x, y;
    local name = name;

    function self:draw()
        love.graphics.rectangel('fill', x * TILESIZE, y * TILESIZE, TILESIZE, TILESIZE);
    end

    function self:update(dt)
        -- DO STUFF
    end

    function self:getX()
        return x;
    end

    function self:getY()
        return y;
    end

    function self:getName()
        return name;
    end

    return self;
end

return Char; 
You could use it like this:

Code: Select all

local Char = require('Char');

local goblin;
local hero;

function love.load()
    goblin = Char.new('goblin', 1, 1);
    hero = Char.new('hero', 1, 10);
end

function love.draw()
    goblin:draw();
    hero:draw();
end

function love.update(dt)
    goblin:update(dt);
    hero:update(dt);
end
Of course you'll still have to implement a lot of stuff to make it an actual character but it is a good base to start from.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests