Entity moving to a x position, not a y

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
n1ghtk1n9
Prole
Posts: 10
Joined: Sat Dec 22, 2012 12:23 am

Entity moving to a x position, not a y

Post by n1ghtk1n9 »

Sorry for the horrible title, I didn't know how to explain it.

I'm trying to make it so a entity(that randomly spawns) moves to another randomly generated x and y position, but for some reason, it's only shifting to the X position, not the Y

Also, how can I get it so that the entity moves slower?
Attachments
Game Help.love
(480.23 KiB) Downloaded 140 times
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Entity moving to a x position, not a y

Post by Lafolie »

I can't figure out what your problem is exactly, or how to recreate it, could you elaborate on that?

Right, so, first of all your game is packaged incorrectly. I'm not sure if it's because you used gzip compression or not, or whether you packaged a folder. See Game Distribution for that.

I'm not sure what the creator of that font was thinking, but you should definitely not use it. It is far too large and is subsequently slow to load (1024+KB, most fonts are ~15KB). Honestly, I cannot stress how terrible this font is.

Your conf.lua currently does nothing. It needs to be in the root project directory (he's best friends with main.lua). If you're not using it, you may want to add t.love.physics = false to that too. :)

You can save yourself a lot of effort by creating your tables differently. Currently you're doing this:

Code: Select all

soldier = {}
soldier.x = 100
soldier.y = 100
soldier.life = 6
soldier.name = "Isperia"
card.draw = function()
    love.graphics.rectangle("fill", soldier.x, soldier.y, 16, 16)
end
--draw call
soldier.draw()
You could do it like this:

Code: Select all

soldier = {
    x = 100,
    y = 100,
    life = 6,
    name = "Isperia",
    draw = function(self)
        love.graphics.rectangle("fill", self.x, self.y, 16, 16)
    end
}
--draw call
soldier:draw()
The latter example is much cleaner (in my opinion) and saves a lot of repetitive typing/tab-completing.

As for moving the image slowly..... that's just a case of adjusting its position by smaller values? Not really sure what you mean here (I must be interpreting the question wrong?).

You also might want to look into object libraries (I recommend slither) or lua metatables so that you can re-use these table structures easily.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests