Search found 3436 matches

by zorg
Wed Dec 09, 2015 11:10 am
Forum: Support and Development
Topic: Creating an image editor... only clearing part of a canvas?
Replies: 8
Views: 2469

Re: Creating an image editor... only clearing part of a canv

Out of curiosity, is there a blendMode or other way of drawing negative or inverted color when drawing a primitive? Would be useful for the grid and selection marquee in my image editor. apparently not What stops one from using subtractive blendmode with the destination buffer (a canvas for example...
by zorg
Tue Dec 08, 2015 3:09 pm
Forum: General
Topic: Code Puzzles
Replies: 44
Views: 17551

Re: Code Puzzles

Ranguna: True, but realize, i only showed that the original puzzle's solution was flawed; the swap function being able to work with arbitrary variables was not a stated goal, nor that it needed to work outside of the chunk where a and b were defined. :3 But yes, to make the swap function work, you e...
by zorg
Mon Dec 07, 2015 7:18 pm
Forum: General
Topic: Code Puzzles
Replies: 44
Views: 17551

Re: Code Puzzles

Edit2: After the answer being posted, i realized that defining the function in that chunk means that the function can access the two vars as upvalues, if one doesn't pass them in as arguments. (The answer though is wrong, since they are being passed in, and the printing happens -inside- the functio...
by zorg
Mon Dec 07, 2015 4:05 pm
Forum: General
Topic: Code Puzzles
Replies: 44
Views: 17551

Re: Code Puzzles

undef wrote:No, but this will:

Code: Select all

function swap(a,b) _G.a, _G.b = b, a end
Except a and b are locals, not globals, so sadly that won't work either. The debug library could probably get the two upvalues and then it might be possible though, as bartbes said before.
by zorg
Mon Dec 07, 2015 4:00 pm
Forum: General
Topic: Code Puzzles
Replies: 44
Views: 17551

Re: Code Puzzles

You're probably going for the usual trick of a = a + b, b = a - b, a = a - b, but since lua has no call-by-reference semantics no such function can actually exist. (At least not without going into the debug library.) So, you're saying that function swap(a,b) a, b = b, a end won't work? Edit: Ah, i ...
by zorg
Mon Dec 07, 2015 12:50 pm
Forum: Support and Development
Topic: wait() function?
Replies: 4
Views: 2141

Re: wait() function?

If Buby wants the wait to not progress to the next line until the time expires, that needs a coroutine-based timer, in order for other things (draw, for example) to keep running meanwhile. That's why I suggested that approach. It's not one I'd recommend personally, though. I was just addressing the...
by zorg
Mon Dec 07, 2015 11:52 am
Forum: Support and Development
Topic: wait() function?
Replies: 4
Views: 2141

Re: wait() function?

Or kikito's timer lib. , which doesn't use coroutines. Then again, a simple example: local timer = 0.0 local pressed = false function love.update(dt) if love.keyboard.isDown('f') then player.y = player.y - (100 * dt) pressed = true end if timer < 1.0 then timer = timer + 1 else player.y = player.y +...
by zorg
Mon Dec 07, 2015 9:52 am
Forum: Support and Development
Topic: Random walking?
Replies: 3
Views: 1370

Re: Random walking?

I'm glad i could help, and alot thanks you too! :3
by zorg
Mon Dec 07, 2015 9:48 am
Forum: Support and Development
Topic: How i can cet the system volume with löve
Replies: 5
Views: 2475

Re: How i can cet the system volume with löve

It can, if the system one uses (on windows at least) has an input called wave out/stereo mix/what-u-hear or similar, since that is the loopback interface, or literally what you hear; openAL can theoretically access that, and you can record from it with lpghatguy's microphone implementation, then use...
by zorg
Mon Dec 07, 2015 7:11 am
Forum: Support and Development
Topic: Random walking?
Replies: 3
Views: 1370

Re: Random walking?

Hi and welcome to the forums! First, you have an img field in your police table, but you set the image so it replaces said table, do this instead: local police function love.load(arg) police = { x = 100, y = 399} police.img = love.graphics.newImage('assets/CharArchive/police.png') end This will load...