Skip to main content
6 votes

Calculate 8 different directional input based on arrow keys combinations

Given 4 variables up left down right with values zero or ...
DMGregory's user avatar
  • 135k
5 votes

Calculate 8 different directional input based on arrow keys combinations

A common method is to combine the opposite direction keys into a single axis, giving you X and Y movements, then you combine the X and Y into a single 2D movement vector. Here's what that code might ...
congusbongus's user avatar
  • 14.8k
5 votes
Accepted

Love2D game and editor in two separate programs

Alright, found it ! I had to add this to the main.lua file in the editor folder and it worked : package.path = package.path .. ";../?.lua" require "core.engine"
Antoine Thiry's user avatar
4 votes
Accepted

Are there any practical applications for clearing the screen with a specific color?

Clearing the color buffer can be optional. For example, if you know that you're going to overwrite every pixel each frame, then you might decide to not clear at all. On the other hand, some drivers ...
Maximus Minimus's user avatar
3 votes

Create a game start-up menu screen with Lua/love 2d

There isn't a built-in menu system for love2d. The developers take a 'do-it-yourself' approach to a lot of such things. Here's an example of how I ended up rigging my menu for my first time: ...
M. Angler's user avatar
3 votes
Accepted

What's wrong with using physics engine in 2d platformer?

It's not necessarily a completely terrible idea but there are significant cons to weigh against the pros you mention. In particular, the physics in a platformer character usually isn't totally (or ...
jhocking's user avatar
  • 15.8k
2 votes

How do I change a LÖVE2D game executable's icon?

The steps below are also covered in a video tutorial (icon topic starts at 2:22). Create an .ico file using GIMP, you can use the game.ico or ...
qubodup's user avatar
  • 124
2 votes

My perlin noise height map doesn't have smooth transitions and goes directly from black to white

There is a bug in the final normalisation code, fortunately it’s easy to fix. You only need to change: map2[x][y] = map2[x][y] * mapMultiplier into: ...
sam hocevar's user avatar
  • 23.9k
2 votes

Got unexpected results from perlin noise. Wondering what it is doing?

You are going outside the 0..255 range. That's why you see these color bands, since you are goint the whole range of values between 0..255 for every integer. You are multiplying by 255 twice. This ...
Nils Ole Timm's user avatar
2 votes

How to create a transparent mask in Love2D

I found the answer -- What I was calling a mask is called a stencil in Love2D. See https://love2d.org/wiki/love.graphics.stencil and Make some black pixels transparent in Love2D.
undefined's user avatar
  • 130
2 votes

How do I represent blended tiles in a mesh/vertex array?

I found a way myself. The key is to have two vertex arrays. In first you store solid blocks. In second you store edges, only if they are visible. Then you simply draw solid blocks first, then edges. ...
Franz Wexler's user avatar
2 votes
Accepted

Change transparency of image at runtime, LOVE2D

Just set the color to white-with-less-than-full alpha before drawing the image. For instance, this would draw your image at around 50% opacity: ...
Noah Witherspoon's user avatar
2 votes

How to deal with rapid acceleration/deceleration from physics forces?

in case anyone's curious, I think I figured it out. I calculated a "terminal velocity" for a given engineForce, that is the speed where drag and the engine would balance out (in this case ...
Adam L.'s user avatar
  • 41
2 votes
Accepted

Drawing rectangle with line's causes join artifact with the graphics api

You are drawing independent and unconnected lines. What you probably want is a polyline. You can get a polyline by passing in more than two points to the line ...
medecau's user avatar
  • 36
2 votes
Accepted

Why check the ball and brick collision twice?

The double check aspect of the code is discussed at this point in the video. The first check lets you know that some sort of collision occurred. However, in order to bounce the ball correctly, you ...
Pikalek's user avatar
  • 12.4k
2 votes

What's wrong with using physics engine in 2d platformer?

This is a matter of opinion. The reference you gave seemed to arguing that depending on what you wanted, using a physics engine could be overkill. I think many of us that have used a physics engine ...
Louis Langholtz's user avatar
1 vote

Implementing framerate independent friction with linear deceleration

The problem you're running into is that you're performing numeric integration with a varying step size. In all but the simplest case (movement at a constant speed), this produces results that vary ...
Mark's user avatar
  • 353
1 vote
Accepted

How to make object that moves with constant speed not overshoot the object it collides with?

At the moment you are checking for a collision between where the player is now and the goal square. Instead, you can define a rectangle which goes from where the player was last frame and where he is ...
ScienceSnake's user avatar
1 vote

Is there a way to set a shader define in Löve?

No, there is no way to do that. However, you can prepend a #define macro to the shader code when creating the shader.
Emily's user avatar
  • 111
1 vote

Is there a way to set a shader define in Löve?

Shaders don't really work that way. Once the shader is compiled, any instance of the name you defined will be replaced with its value. If you want something that changes throughout your program, use a ...
steVeRoll's user avatar
1 vote

How can I properly render multiple layers/components in game?

My first idea was to create a screen/gamestate for each of these components, and stack them on top of each other so each is running/displaying at the same time. This feels like it's not a very proper ...
idbrii's user avatar
  • 828
1 vote

Love2D STI library not drawing map at all (black screen)

I realized you need to be careful exporting lua maps from Tiled, because they are automatically named like "[your map name]..lua". I'm not sure why this is, but when I did Export As instead and named ...
Alexis Purslane's user avatar
1 vote

Love2D how to zoom out map?

This code just uses individual tile images that must each be 100x100 px. The zoom still needs a bit of tweaking. ...
Unspecified's user avatar
1 vote

Löve2d: How can i select object with mouse if it's overlap?

If I understand your question correctly, you are asking when the two cards are on top of eachother how do you decide which gets grabbed? I guess you would chose whichever one is on top visually right? ...
dyl4n130's user avatar
1 vote
Accepted

Love2D and 'Tiled' - Detect if player is over certain tile/Collision

Indexing a 2D array represented as a 1D array is done like this: index = x + y * width Where width is sometimes known as ...
congusbongus's user avatar
  • 14.8k
1 vote

.PNG changes color in Love2D

More specifically, the drawing color set by love.graphics.setColor acts as a kind of mask, and stays until it is overridden by another call to love.graphics.setColor. So you may have to save the old ...
Mutos's user avatar
  • 111
1 vote
Accepted

.PNG changes color in Love2D

Set the color to white before calling the draw method: ...
Selti99's user avatar
  • 26
1 vote
Accepted

Unwanted line between chunks in heightmap infinite terrain

It's due to you scaling the map by your map multiplier. If the difference between the min and max values is different you will scale one sector higher and one lower causing the same noise value to end ...
Nils Ole Timm's user avatar
1 vote
Accepted

Love2D: Calling two files

The main.lua file is automatically executed from the Löve application and the overriden functions love.load, ...
user6245072's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible