Search found 1140 matches

by ivan
Thu Dec 14, 2017 6:26 pm
Forum: Support and Development
Topic: Game with separate files tryout
Replies: 32
Views: 735

Re: Game with separate files tryout

local square = {x = 100, y = 100, width = 50, height = 50, speed = 20} function square.update( dt ) if love.keyboard.isDown("right") then square.x = square.x + square.speed * dt end if love.keyboard.isDown("left") then square.x = square.x - square.speed * dt end if love.keyboard.isDown("up") then s...
by ivan
Thu Dec 14, 2017 6:15 pm
Forum: Support and Development
Topic: Game with separate files tryout
Replies: 32
Views: 735

Re: Game with separate files tryout

You're almost there: function love.update( dt ) square.update(dt) end function love.draw() square.draw() end Since your square is "local" it cannot be accessed outside of the square.lua file. You have 2 options there, either keeping the "square" global OR returning the square to the main file: retur...
by ivan
Wed Dec 13, 2017 9:52 am
Forum: Support and Development
Topic: How to make a platformer without knowing much about physics ?
Replies: 6
Views: 280

Re: How to make a platformer without knowing much about physics ?

I've written a tutorial precisely on this topic: http://2dengine.com/doc/gs_platformers.html In short, you need a basic understanding of the underlying physics, fortunately it's not very hard. Yes, modiX is correct, the simplest solution is to use "impulses" or instant changes in velocity. There are...
by ivan
Sat Dec 09, 2017 8:37 am
Forum: Support and Development
Topic: Clean way to destroy a body will all its shapes
Replies: 6
Views: 240

Re: Clean way to destroy a body will all its shapes

First all there is a difference between shapes and fixtures in the newer versions of Box2D. One shape could be shared along many fixtures or bodies - that's why there is no "shape:destroy()". You don't need to destroy the shapes yourself (nor should you want to), Lua's garbage collector should be ab...
by ivan
Sat Dec 09, 2017 7:21 am
Forum: Support and Development
Topic: Physics - Limit velocity
Replies: 8
Views: 657

Re: Physics - Limit velocity

modiX, you're on the right path, but your terminology is slightly off. Please note that force and power mean very specific things in physics. ;) Ok, back to your question - you want to limit the velocity of a body. The easiest way to do that is using linear damping. If you want to "clamp" the veloci...
by ivan
Fri Dec 08, 2017 3:46 pm
Forum: Support and Development
Topic: Physics - Limit velocity
Replies: 8
Views: 657

Re: Physics - Limit velocity

I recommend: --- Clamp length -- @param v vector -- @param d maximum length -- @return initial length of the vector function clamp(v, d) local x, y = v.x, v.y local d2 = math.sqrt(x*x + y*y) if d2 > d then v.x = x/d2*d v.y = y/d2*d end return d2 end What is the correct way to limit the speed of my o...
by ivan
Sat Dec 02, 2017 9:48 pm
Forum: Games and Creations
Topic: Space Invaders: 1K Challenge
Replies: 4
Views: 442

Re: Space Invaders: 1K Challenge

Not bad, Sefan. it's a decent try. Would be nice if the game reset when the invaders reach the bottom. Plus, on my resolution I can move to the right and "seemingly evade" their attack altogether. :) Note that you can probably shave off a few bytes from: if I<1 then O=O+.05 else O=O-.05 end by using...
by ivan
Fri Dec 01, 2017 5:28 pm
Forum: Games and Creations
Topic: Space Invaders: 1K Challenge
Replies: 4
Views: 442

Re: Space Invaders: 1K Challenge

This is what I got so far L=love;G=L.graphics;O=L.keyboard.isDown;P=pairs;H=G.draw;Z={{11,8,"001401401000140G0001101110110G111110G011014010100011011000"},{17,8,"400011144400111444001114440011144GG10GGGGGGG11"}}for a,v in P(Z)do v[3]=v[3]:gsub("4","0000"):gsub("G","1111111"):gsub("1","ÿÿÿÿ"):gsub("0"...
by ivan
Fri Dec 01, 2017 5:23 pm
Forum: Games and Creations
Topic: Space Invaders: 1K Challenge
Replies: 4
Views: 442

Space Invaders: 1K Challenge

It's that time of year again! The goal of this challenge is to create a Space Invaders clone, but here is the catch: 1.all of the code must be contained a single Lua file which should be under 1K (1024 ANSI characters) 2.no external assets or files allowed (can't use external images, sound files, fo...
by ivan
Thu Nov 30, 2017 12:31 pm
Forum: Support and Development
Topic: Font density
Replies: 8
Views: 321

Re: Font density

Hey TC, we all tried to help you but your question was not stated clearly. The problem is with the way you are loading the font: Font=love.graphics.newFont("somefont.ttf",24) tells Love2d that your font should be rasterized so that it's exactly 24 pixels high. The easiest solution is to load multipl...