Search found 612 matches

by ReFreezed
Thu Sep 22, 2022 5:38 pm
Forum: Support and Development
Topic: Entity class can't read body variable
Replies: 1
Views: 923

Re: Entity class can't read body variable

'body'' and 'shape' are not variables in the function - they are fields in the table that you return. Move the body and shape creation to before the return statement to solve the issue: local body = love.physics.newBody(world, x, y, "dynamic") local shape = love.physics.newCircleShape(50) ...
by ReFreezed
Wed Sep 21, 2022 6:40 pm
Forum: General
Topic: A way to do simple shadows
Replies: 25
Views: 9851

Re: A way to do simple shadows

Well, the sprites are flat, so all you can get are flat shadows. You'd need 3D geometry to some extent for more 3D-looking shadows. Since they look the most flat when the light comes from the side it could be a good idea to design your game/levels such that that situation doesn't happen.
by ReFreezed
Wed Sep 21, 2022 1:30 am
Forum: General
Topic: A way to do simple shadows
Replies: 25
Views: 9851

Re: A way to do simple shadows

You can simply use the scale and shear arguments of love.graphics.draw() and some trigonometry to transform the shadow. Here's an example that handles a light source from any direction:
SimpleShadows.love
(3.23 KiB) Downloaded 166 times
_screenshot.png
_screenshot.png (46.23 KiB) Viewed 3595 times
by ReFreezed
Tue Sep 20, 2022 1:34 pm
Forum: Support and Development
Topic: Calling Function from Collided Object in Windfield?
Replies: 8
Views: 1863

Re: Calling Function from Collided Object in Windfield?

Just use another ipairs loop, something like this: function getYarrowByCollider(collider) for i, yarrow in ipairs(yarrows) do if yarrow.collider == collider then return yarrow end end return nil -- No yarrow found! end function playerInteract(x, y) local colliders = world:queryCircleArea(x, y, 10, {...
by ReFreezed
Mon Sep 19, 2022 3:26 pm
Forum: General
Topic: Midi Visualizer
Replies: 2
Views: 1435

Re: Midi Visualizer

I would never have imagined "MIDI" and "boids" being in the same sentence. :d
by ReFreezed
Mon Sep 19, 2022 3:15 pm
Forum: General
Topic: Coroutines are awesome
Replies: 26
Views: 12808

Re: Coroutines are awesome

Interesting example about visualizing algorithms. I was mainly thinking about games, but I see how coroutines could work in other simpler programs. Not sure specifically the rendering fits well there though as you could just render stuff and call love.graphics.present() whenever you want in the midd...
by ReFreezed
Mon Sep 19, 2022 1:20 pm
Forum: Support and Development
Topic: Calling Function from Collided Object in Windfield?
Replies: 8
Views: 1863

Re: Calling Function from Collided Object in Windfield?

All require() does is run the code in the specified module/file if it hasn't already run, and returns whatever the module returned (if anything). Since your code (in the posted snippets, at least) defines global functions, anyone can access those functions as long as those modules were required at s...
by ReFreezed
Sun Sep 18, 2022 8:46 pm
Forum: General
Topic: Coroutines are awesome
Replies: 26
Views: 12808

Re: Coroutines are awesome

The comparison to threads was mostly a joke - of course they have significant differences. I've also used coroutines more than threads, but I've seldom needed to use either. Using coroutines does make sense when decoding streaming data one chunk at a time, like can be done with gifload (though when ...
by ReFreezed
Sun Sep 18, 2022 5:56 pm
Forum: Support and Development
Topic: Calling Function from Collided Object in Windfield?
Replies: 8
Views: 1863

Re: Calling Function from Collided Object in Windfield?

queryCircleArea() returns a list of colliders, not yarrows, so for each collider you'll have to look through your list of yarrows to find the one with the relevant collider (yarrow.collider).
by ReFreezed
Sun Sep 18, 2022 12:38 pm
Forum: Support and Development
Topic: Wraparound a Table of Tables [Solved]
Replies: 9
Views: 1670

Re: Wraparound a Table of Tables

What isn't working? The logic seem to wrap around fine. I tried drawing this on the right edge:

Code: Select all

   |
 x |
 xx|
  x|
  x|
   |
Running the simulation shows it wrapping around to the left side. Same happens vertically.