love2d

Love2d cursor positions

眉间皱痕 提交于 2019-12-25 08:19:05
问题 I have a question about the love2d(lua script) cursor functions. I wan't to make an area to click to make an action happen. I started on a track of for loops in the x and y parameters. The only other problem ive thought of is if it will go through a for loop of number/coordinates and finish on 1 number which the love.mouse.get() will end up on and allow for the cursor to end up being clicked on that last coordinate(one pixel). for r = 660, 770 do --the x coordinates mx = love.mouse.getX(r)

How to achieve a player that is not just a rectangle

北城以北 提交于 2019-12-24 23:44:21
问题 My goal is to achieve a player that is not just a rectangle. This is my love.load and love.draw : local AdvTiledLoader = require("AdvTiledLoader.Loader") require("camera") function love.load() love.graphics.setBackgroundColor( 204, 255, 204 ) AdvTiledLoader.path = "maps/" map = AdvTiledLoader.load("map.tmx") map:setDrawRange(0, 0, map.width * map.tileWidth, map.height * map.tileHeight) camera:setBounds(0, 0, map.width * map.tileWidth - love.graphics.getWidth(), map.height * map.tileHeight -

Setting a variable in a for loop (with temporary variable) Lua

浪子不回头ぞ 提交于 2019-12-23 21:15:28
问题 I have a for loop in lua, and I'm trying to set variables inside that for loop using the iterator variable. I need it to set these variables: damage1 damage2 damage3 damage4 damage5 damage6 damage7 damage8 damage9 damage10 damage11 Of course I'm not going to assign them all, as that would be breaking the rules of D.R.Y. (Don't Repeat Yourself). This is what I figured would work: for i = 0, 11 do damage..i = love.graphics.newImage('/sprites/damage/damage'..i..'.png') end Don't mind the love

Mandelbrot Set through shaders in GLSL with LOVE2d renders a circle, not a fractal

[亡魂溺海] 提交于 2019-12-23 01:52:21
问题 I'm trying to render a Mandelbrot Set using GLSL, but all I get is a full circle... I have checked the maths a lot, and I simply cannot find the error, so I thought maybe the problem was semantic. Is anyone able to see what's wrong? Also, could anyone give me insights on organization, structure, etc? I'm trying to learn proper coding, but it's hard to find material on styling. Obs.: The shader can be applied over any image The idea is simple (you may skip this): checkConvergence returns true

How to get “sizeof” a table in Lua?

隐身守侯 提交于 2019-12-12 18:54:53
问题 I'm dabbling in Love2D using Lua and have just implemented a StateMachine to handle transitions between a set of states e.g. IntroState, MenuState, PlayState etc.. In previous programs I usally release objects and/or states that are only a "one-time-deal", iow will only be presented to the player once during the lifetime of the application. In C++ I use the sizeof operator which returns the size in bytes of the passed object, just to get some feedback of how much memory I release at a certain

Returning A Sorted List's Index in Lua

微笑、不失礼 提交于 2019-12-11 11:13:04
问题 I access object properties with an index number object = {} object.y = {60,20,40} object.g = {box1,box2,box3} -- graphic object.c = {false,false,false} -- collision -- object.y[2] is 20 and its graphic is box2 -- sorted by y location, index should be, object.sort = {2,3,1} I know table.sort sorts a list, but how can I sort the y list that returns index for the purpose of drawing each object in-front depending on the y location. Maybe the quicksort function can be edited, I don't understand it

Inheritance in Love2d and Lua

你离开我真会死。 提交于 2019-12-11 03:39:24
问题 I have a class with this set of values and functions: require("class") entity = class:new() function entity:new() self.x = 100 self.y = 100 self.width = 32 self.height = 32 self.info = "entity" self.alive = true self.color = {r = 255, g = 0, b = 0} return self end function entity:load() end function entity:update() if self.alive then end end function entity:draw() if self.alive then love.graphics.setColor(self.color.r, self.color.g, self.color.b) end end function entity:destroy() self.alive =

lua -> how to modify these arguments to be const, or what should I do?

你说的曾经没有我的故事 提交于 2019-12-11 03:08:25
问题 all! I came here because I have one problem bugging me for quite some time now. I am using love2d engine as a 'graphical' addition to lua scripting, but this problem is of lua type (I believe, at least). I have a function: createNew_keepOld = function (oldImgData, oldImgDraw) local newImgData = oldImgData --I am assigning old value to another variable local newImgDraw = oldImgDraw --I am doing the same thing as with data for x = 0, newImgData:getWidth()-1 do for y = 0, newImgData:getHeight()

Lua: Adding multiple rows to tables

可紊 提交于 2019-12-10 15:37:48
问题 Ok, so I'm looking to quickly generate a rather large table. Something that would look like this: table{ {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, } Only the table would contain far more rows, and far more values in those rows. I know using table.insert() I can easily add however many I need to a single row, but is there anyway I can also add whole new rows without typing it all out? 回答1: Use a for loop. t = { } for i = 1,100 do table.insert(t, i) -- insert numbers from 1 to 100 into t end 2D

How to create a walking animation in LOVE 2D

╄→尐↘猪︶ㄣ 提交于 2019-12-09 05:36:22
问题 So I was wondering how to change an image of character I've created depending on the key I've pressed/am pressing? My ultimate going to to have a walking animation occuring when "d" (or any of the wasd keys) is pressed but then he stands still when the "d" key has just been pressed etc. All images have been created already. I've tried this but it didn't work out: function love.load() if love.keyboard.isDown("a") then hero = love.graphics.newImage("/hero/11.png") elseif love.keyboard.isDown("d