Search found 1137 matches

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: 189

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: 628

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: 628

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: 391

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: 391

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: 391

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: 290

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...
by ivan
Thu Nov 30, 2017 6:16 am
Forum: Support and Development
Topic: Font density
Replies: 8
Views: 290

Re: Font density

I'll assume this topic is about "letter spacing". You see, most fonts are designed to look well at a predefined spacing. Some fonts contain kerning info that adjusts the positions of specific pairs of letters. All you need to do is start FontForge and open up the font that you want to massacre... I ...
by ivan
Wed Nov 29, 2017 5:11 pm
Forum: Support and Development
Topic: converting Tetriminos into polygons (or tracing a poly shape around square tiles)
Replies: 5
Views: 341

Re: converting Tetriminos into polygons (or tracing a poly shape around square tiles)

so to summarise, in the end i want to draw square maps in tiled, and trace the boundaries to make giant polygons out of them... the second usage MAY be, to create collision polygons out of sprites on the fly.... yes i think it might be slow, and cannot happen mid game... The problem in my opinion i...
by ivan
Wed Nov 29, 2017 5:00 am
Forum: Support and Development
Topic: converting Tetriminos into polygons (or tracing a poly shape around square tiles)
Replies: 5
Views: 341

Re: converting Tetriminos into polygons (or tracing a poly shape around square tiles)

First of all, why do you need to represent tetrominoes as individual polygons? Marching squares along with triangulation is certainly NOT the most "optimal" approach. In fact, it will make the problem much harder for you. Note that your code doesn't actually "march" or trace around the contours. You...