Page 22 of 91

Re: "Questions that don't deserve their own thread" thread

Posted: Sun Sep 14, 2014 12:33 pm
by Zilarrezko
bartbes wrote:
Ortimh wrote:I believe it is because of WinRAR
Kind of, but mostly because you tell it to create a rar file, and not a zip file.
This seems like the likely case actually. I remember that when I try and make a .7z then make it a .love. It wouldn't work. So make it a .zip rather than a .rar (at this point we'll assume this is the problem.). I'd try myself, but I don't like winrar, and I'm too tired to download and try it.
ELFUERTE wrote:Hm,quick question. Since moving the character tile by tile looks a bit choppy,would you suggest moving the character pixel per pixel? Is this a viable alternative?
You can definitively implement this. A couple ways is some simple trigonometry. Using some nice tan's and a couple x, y coords. Then an update function, and you could have the player move from one point, to another point. This is a smooth way to move the player, however I think you would have to make changes to your moveto function (I think that's what it's called.). Or you could do tweening, if that's your thing. To be honest when I tried to look up tweening, I couldn't find much. But you could use kikito's tweening thing. I think I might personally browse his code to see how it works. But you can use tweening to move between two coords.

However, I really need to sleep right now, and I hope something out of the paragraph was readable sorry if it isn't. So I'm going to go to bed, and if you haven't gotten help by "tomorrow" (It's 5:30 am for me, and I sleep during the day.) than I'll help you out there.

Re: "Questions that don't deserve their own thread" thread

Posted: Sun Sep 14, 2014 6:26 pm
by Morzan
Hey all!

Can löve encode images, text or files with base64? I know that it can decode it, but can it encode too? That would be awesome.

Thanks!

Re: "Questions that don't deserve their own thread" thread

Posted: Sun Sep 14, 2014 8:02 pm
by bartbes
I don't think so. It's fairly easy to write an encoder for it, especially with luajit's bitop module.

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Sep 15, 2014 11:38 am
by Bya
I'm trying to make a "hitbox" for my character's attack (making a platformer). I want the hitbox object to "follow" the player and be "bound" to it, but I'm not entirely sure how to do that. My player is coded as follows

Code: Select all

player = {}
	player.b = love.physics.newBody(world, 400, 200, "dynamic")
	player.b:setMass(10)
	player.s = love.physics.newRectangleShape(32,54)
	player.f = love.physics.newFixture(player.b, player.s)
	player.f:setRestitution(0.4)
	player.f:setUserData("Knight")
	player.x = 50;
	player.y = 50;
I attempted to code the hitbox similarly like a rectangle object, such as

Code: Select all

swordhitbox = {}
		swordhitbox.b = love.physics.newBody(world, player.b, player.s, "static")
		swordhitbox.s = love.physics.newRectangleShape(25,25)
		swordhitbox.f = love.physics.newFixture(swordhitbox.b, swordhitbox.s)
		swordhitbox.f:setUserData("swordhitbox")
But it doesn't work, likely because I tried substituting player.b and player.s for the x and y coordinates. I figured that by putting in what (I assume to be) the x and y coordinates for the player, that the hitbox would always follow the player. Additionally, how would I make it so that this hitbox only exists when a key is pressed down?

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Sep 15, 2014 2:03 pm
by Morzan
bartbes wrote:I don't think so. It's fairly easy to write an encoder for it, especially with luajit's bitop module.
So i should make a lua file that'll encode any file with base64 and then return the encoded data?
I would do that, but i never used LuaJIT. If you can give me any help about this i would really appreciate that! Thanks!

Edit: Nevermind, i found this: https://gist.github.com/bortels/1436940

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Sep 15, 2014 6:31 pm
by megalukes
Is it just me or this library in the Love Wiki is not working anymore? I'm looking for a serialization library, which one do you guys recommend?

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Sep 15, 2014 6:35 pm
by slime
I've heard Ser does the job pretty well.

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Sep 16, 2014 4:44 pm
by Zilarrezko
Anyone know how in shaders to create an array with as many indices as an int that you pass it.

kinda like...

Code: Select all

extern number lightNum; //let's just pretend that it was passed a 5.

extern vec3[lightNum] lights;

yaddayaddayadda

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Sep 16, 2014 8:55 pm
by slime
You can't have dynamically sized arrays in GLSL like that, but you can do something like this:

Code: Select all

#define MAX_LIGHTS 10

extern int numLights;
extern vec3 lights[MAX_LIGHTS];

vec4 effect(vec4 vcolor, Image tex, vec2 texcoords, vec2 pixcoords)
{
    for (int i = 0; i < numLights; i++)
    {
        // etc.
    }

    // ...
}

Code: Select all

shader:sendInt("numLights", 5)
shader:send("lights", {x,y,z}, {x,y,z}, {x,y,z}, {x,y,z}, {x,y,z})
However, keep in mind loops (and other sorts of conditional things, like if-statements) can have a very large impact on performance, especially on older hardware.

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Sep 16, 2014 11:13 pm
by Dr.Tyler O.
Is it possible to use Fixture:setFilterData() while still letting those fixtures produce collision callbacks? I'm aware that it sounds silly but the collision callbacks are what I'm using to detect whether the players in my video game touch items. I just don't want the items to slow the player down with collisions.