Page 37 of 91

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

Posted: Sun Jun 07, 2015 12:27 pm
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.

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

Posted: Sun Jun 07, 2015 3:23 pm
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.

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

Posted: Fri Jun 12, 2015 7:34 pm
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?

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

Posted: Thu Jul 02, 2015 9:56 pm
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.

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

Posted: Sat Jul 11, 2015 1:41 pm
by Jack Dandy
Hey, where did all the in-wiki tutorials that were featured in https://www.love2d.org/wiki/Category:Tutorials go to?

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

Posted: Sat Jul 11, 2015 2:51 pm
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.

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

Posted: Fri Jul 17, 2015 2:12 pm
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?

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

Posted: Fri Jul 17, 2015 3:01 pm
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.

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

Posted: Fri Jul 17, 2015 3:17 pm
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

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

Posted: Sat Jul 18, 2015 12:20 am
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.