"Questions that don't deserve their own thread" thread

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Locked
User avatar
BlueWolf
Prole
Posts: 12
Joined: Fri May 29, 2015 7:55 pm

Re: "Questions that don't deserve their own thread" thread

Post by BlueWolf »

BlueWolf wrote:Is it that much? Imagine you have 32 enemies and 16 bullets on the screen and bam, you have 512 checks per frame. Unless you do some fancy space partitioning, that is. Or am I still missing something obvious? Is there some other way to check if bullet hit enemy? I just feel like modern computers should be able to handle couple dozen moving sprites at the same time.
All right... hurr durr. Of course it going to be slow when you attach ZeroBrane Studio debugger to it. I mean, I knew it was slowing things down but I somehow still forgot to take it into account. Without debugger attached I can do something like 512 * 512 (262144) checks before it starts dipping below 60 fps. Which is more like what I expected from modern computer's performance.

Btw, debugger tanks frame rate HARD. I imagine it won't be great for debugging any sort of slightly bigger game.
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: "Questions that don't deserve their own thread" thread

Post by I~=Spam »

That is because in order for zerobrane to be able to debug any lua scripts it must turn on per line debugging. This tells lua to run code one line at a time (using per line debug hooks). Mobdebug (the library that zerobrane loads into the debugging lua program to make the debugging possible) just listens on a port for instructions (ie new breakpoint pause, stop, etc.). The only way to get it to run faster is to disable the per line debugging. This will make lua stop per instruction. While this will be a lot faster it kind of defeats the purpose of debugging because you cannot jump to the line running anymore (at least I don't think you can) and you definitely cannot run code on a line per line bases.

In a nutshell, it is not zerobrane's fault. In fact, zerobrane and the library it uses are pretty efficient. Lua doesn't run code on a line per line bases so forcing it to makes the lua vm have to slow down a lot.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

Re: "Questions that don't deserve their own thread" thread

Post by Jack Dandy »

Alright, I looked through various gamestate libraries that are available on the wiki, and I'm not sure about something:

What can you actually consider to be a "Gamestate"?
From what I'm seeing, it mostly refers to really different aspects of the game: For example, Main Menu - Pause screen - actual gameplay...

What I'm currently looking for though, is much simpler:
In a simple turn-based strategy game, I want to press "a" to highlight a character's attack range, and when you press the mousebutton somewhere inside that range, to execute a function.

Can that be considered a gamestate as well? How would you advise me to go about this task?
paulclinger
Party member
Posts: 227
Joined: Thu Jun 28, 2012 8:46 pm

Re: "Questions that don't deserve their own thread" thread

Post by paulclinger »

BlueWolf wrote:debugger tanks frame rate HARD. I imagine it won't be great for debugging any sort of slightly bigger game.
@BlueWolf, @I~=Spam is correct with what he said about per line hook and debugging. I've tried to optimize mobdebug, but it's running Lua code in a per-line hook, which, by itself, is going to slow you down. This is not to say you can't make it run faster. You can turn debugging on and off, which allows you to "bracket" the fragment of your code that you want to debug and for everything else (when the debugging is off), you get normal performance without any penalty (as the hook is turned off at that time). Obviously, breakpoints and all other features only work while debugging is on. See the example in the documentation: http://studio.zerobrane.com/doc-lua-deb ... off-and-on

Paul.
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

Re: "Questions that don't deserve their own thread" thread

Post by Jack Dandy »

Hey, where did all the in-wiki tutorials that were featured in https://www.love2d.org/wiki/Category:Tutorials go to?
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by s-ol »

paulclinger wrote:
BlueWolf wrote:debugger tanks frame rate HARD. I imagine it won't be great for debugging any sort of slightly bigger game.
@BlueWolf, @I~=Spam is correct with what he said about per line hook and debugging. I've tried to optimize mobdebug, but it's running Lua code in a per-line hook, which, by itself, is going to slow you down. This is not to say you can't make it run faster. You can turn debugging on and off, which allows you to "bracket" the fragment of your code that you want to debug and for everything else (when the debugging is off), you get normal performance without any penalty (as the hook is turned off at that time). Obviously, breakpoints and all other features only work while debugging is on. See the example in the documentation: http://studio.zerobrane.com/doc-lua-deb ... off-and-on

Paul.
That would be a cool feature for zbstudio! A "debug this function" button that wraps the function in mobdebug start/stop statements and launches the application regularly.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
louie999
Prole
Posts: 46
Joined: Fri Mar 06, 2015 9:01 am

Re: "Questions that don't deserve their own thread" thread

Post by louie999 »

Just a little question, say there are these lua files, file1, file2 and file3, file2 has require "file1" so file2 can use the functions, variables etc. in file1 then file3 has require "file2", so file3 can also access file1?(as file2 has require "file1") or am I wrong?

Code: Select all

fun = true
school = true

function isItFun()
    if school then
       fun = false
    end
    if not fun then 
       me:explode()
    end
end
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: "Questions that don't deserve their own thread" thread

Post by airstruck »

If file2 requires file1, it can see any globals defined by file1.

If file3 then includes file2, it can also see any globals defined in file1, because they are globals.

But globals are evil, so what you really want is for each file to return the things it's supposed to expose, and explicitly require the things it needs.
louie999
Prole
Posts: 46
Joined: Fri Mar 06, 2015 9:01 am

Re: "Questions that don't deserve their own thread" thread

Post by louie999 »

time thief wrote:If file2 requires file1, it can see any globals defined by file1.

If file3 then includes file2, it can also see any globals defined in file1, because they are globals.

But globals are evil, so what you really want is for each file to return the things it's supposed to expose, and explicitly require the things it needs.
Ok thx :D

Code: Select all

fun = true
school = true

function isItFun()
    if school then
       fun = false
    end
    if not fun then 
       me:explode()
    end
end
Sarcose
Prole
Posts: 48
Joined: Wed Jul 08, 2015 12:09 am

Re: "Questions that don't deserve their own thread" thread

Post by Sarcose »

Hey guys, I just want to say, this language is great, probably the first time I've ever been able to make real progress on understanding development. I'm stuck and I don't really think this problem deserves a thread so: I'm trying out a game concept based on the Fine Tile-based scrolling tutorial on the wiki (so I can mess around with mechanics without having to do more elaborate mapping as in spritebatching), and I made a map with "zooming" and resizing with the window, using scaling. The problem is, it places the map at the top-left of the window and I can't figure out how to draw it "centered" in the window -- this is most easily seen by zooming way out and maximizing the window, and scrolling around. I'm sorry if this solution is obvious, but all my solution concepts are sort of half-formed (like, find where the top corner of the map would be drawn based on arbitrary window size, but I can't figure out how precisely to do that -- it could be that my mind is fucked right now from tiredness), and I think I just need a little push.

I hope uploading the .love is okay for this sort of question.

Z and X "zoom" in and out, respectively. It is constrained 1:1 on scaling the tiles for zooming, to keep it from stretching unevenly, so resizing the window would necessarily create blackspace, and centering it in this blackspace is the goal. (sidenote: I'm aware that I have terrible naming conventions right now; I think I've developed an understanding patched together from different tutorials with different conventions, and have yet to really think about how I want to do it -- I'm also aware that I'm committing the sin of polluting the global namespace and have yet to fix that)

Thanks for any advice you guys can offer.
Attachments
Topdown 0.05 noncentered.love
some shitty map of tiles with zooming and scrolling
(2.72 KiB) Downloaded 142 times
Locked

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 210 guests