Search found 1078 matches

by micha
Thu Jun 25, 2015 9:44 am
Forum: Support and Development
Topic: math.random fluctuation
Replies: 8
Views: 1464

Re: math.random fluctuation

I don't have a complete solution for you but I noticed something: Whenever the random flickering occurs, at the right side of the screen two block appear one on top of the other (usually leaving no gap at all). So I think your block-generation logic is broken somewhere. You should start digging there.
by micha
Mon Jun 22, 2015 5:36 pm
Forum: Support and Development
Topic: math.random fluctuation
Replies: 8
Views: 1464

Re: math.random fluctuation

I put in some debug code with prints, and saw that when it randomises the number, the variable fluctuates between 1 and 2 for a few seconds before settling on 1 number. By this time, all of the columns of blue have spawned in 1 place. I had a look at it and I cannot reproduce the problem. Can you e...
by micha
Mon Jun 15, 2015 3:02 pm
Forum: Support and Development
Topic: Circular Cursor Lock
Replies: 8
Views: 1399

Re: Circular Cursor Lock

micha what about less than? In that case, the function returns the actual mouse coordinates. That means that the mouse can freely move inside the circle, but if it is outside, the mouse position is corrected. I noticed an error I made in the previous code snippet. This is the corrected version. fun...
by micha
Mon Jun 15, 2015 7:42 am
Forum: Support and Development
Topic: Circular Cursor Lock
Replies: 8
Views: 1399

Re: Circular Cursor Lock

Lets say the player is at coordinates (px,py) and the mouse at (mx,my) and the desired radius is r then you can calculate the coordinates you are looking for like this: function getPositionOnCircle(px,py,mx,my,r) local dx,dy = mx-px, my-py local dist = math.sqrt(dx^2+dy^2) if dist > r then return px...
by micha
Sat Jun 13, 2015 9:59 am
Forum: Support and Development
Topic: Error: Bad Argument #2 to rectangle
Replies: 2
Views: 685

Re: Error: Bad Argument #2 to rectangle

The error means that the second argument in the rectangle call is nil, but a number is needed. The second argument is player.x. It is defined in player.load, player.load is never run. To fix this, add player.load to line ~24 in menu.lua (where you switch from menu to gameplay).
by micha
Fri Jun 05, 2015 2:00 pm
Forum: Games and Creations
Topic: Sokoban
Replies: 8
Views: 1801

Re: Sokoban

Just in case you are interested or up for a challange: Some time ago I found a research paper on the Procedural generation of sokoban levels.
by micha
Fri Jun 05, 2015 11:33 am
Forum: Support and Development
Topic: Attack intervals?
Replies: 8
Views: 2276

Re: Attack intervals?

Kingdaros solution is better in one aspect: If the framerate is really low, less than one frame per cooldown, then the effective cooldown is raised to the framerate (if you follow my solution). This small correction should make Kingdaros solution correct. function love.load() -- initialize timer coo...
by micha
Fri Jun 05, 2015 5:47 am
Forum: Support and Development
Topic: Attack intervals?
Replies: 8
Views: 2276

Re: Attack intervals?

Hi and welcome to the forum. You can implement time intervals by having a cooldown-timer. function love.load() cooldown = 0 end function love.update(dt) cooldown = math.max(cooldown - dt,0) if love.keyboard.isDown(' ') and cooldown == 0 then cooldown = 1 -- cooldown-time in seconds shoot() end end
by micha
Thu May 28, 2015 8:08 am
Forum: Support and Development
Topic: Movement Relative to Mouse
Replies: 13
Views: 2137

Re: Movement Relative to Mouse

Can you provide a code or more explanation? Sure. Here is some code (I renamed "private" to "p" so that it is shorter): local mouseX, mouseY = p.camera:getWorldPosition(love.mouse.getPosition()) local angle = game.math.angle(mouseX, mouseY, p.x, p.y) local dx = math.cos(angle) -- this calculates th...
by micha
Wed May 27, 2015 11:48 am
Forum: General
Topic: Teaching LÖVE
Replies: 14
Views: 3143

Re: Teaching LÖVE

For game ideas, have a look at the tutorial series by Tom Francis. It is in GameMaker, not LÖVE, but it might be useful as inspiration. He is doing a top-down shooter, I think.