• Facepunch Trade-Off Game Development
    578 replies, posted
  • [QUOTE=jack5500;34892452]The newest downloads and media aren't working... :/[/QUOTE] Fucking hell. Sorry about that. Problem on my side. I put swift_and_shift.zip instead of swiftandshift.zip.
  • It's okay guys I fixed the turbo boost bug. I was unawares of love 0.8.0 I guess I'll upgrade or some shit. I'm trying to make it so you can add codeable objects to the map but my lua is not really up to scratch so I'm tearing my eyes out. Also, fucking code man - what is up with this whole rename the library shit. Is that a standard practice in lua? I hope not. Also do all arrays start at 1 in lua, or is it just that guys explode function? I'm so confused at this code sometimes I just like fucking write something I think should work and cross my fingers.
  • [QUOTE=iPope;34893851]Also, fucking code man - what is up with this whole rename the library shit. Is that a standard practice in lua? I hope not.[/QUOTE] I always do that, it just speeds things up and you have to type less. [QUOTE=iPope;34893851]Also do all arrays start at 1 in lua, or is it just that guys explode function?[/QUOTE] Yes, Lua arrays start at 1.
  • [QUOTE=Darkwater124;34894002]I always do that, it just speeds things up and you have to type less. Yes, Lua arrays start at 1.[/QUOTE] Someone said it doesn't since you didn't set them as local. Also, on character variable names isn't a preference, it's a very very bad habit.
  • [QUOTE=Darwin226;34894049][B]Someone said it doesn't since you didn't set them as local.[/B] Also, on character variable names isn't a preference, it's a very very bad habit.[/QUOTE] It speeds things up in terms of fewer keystrokes, but you only get the actual [B]performance[/B] boost if it's local.
  • [QUOTE=BlkDucky;34894102]It speeds things up in terms of fewer keystrokes, but you only get the actual [B]performance[/B] boost if it's local.[/QUOTE] He said it speed things up AND you have less to type. So the first one was obviously about performance.
  • Okay so now I have to check it out. [LUA] _g = love.graphics function love.load() local t = love.timer.getMicroTime() for i=1, 10000 do love.graphics.point(0, 0) end print(love.timer.getMicroTime() - t) t = love.timer.getMicroTime() for i=1, 10000 do _g.point(0, 0) end print(love.timer.getMicroTime() - t) end [/LUA] Result of 3 executions: [CODE] 0.0018206217901025 0.001087894605007 0.0016644974093651 0.0011979902883468 0.0016570332954871 0.0012480620498536 [/CODE] Well it seems like it -does- matter, only a tiny bit.. Anyway I'm still keeping it as less to type. Also, here's the result of having local _g: [CODE] 0.0016707175018382 0.0011233491495659 0.0016887557758309 0.0010123204519914 0.0015503586655541 0.0010533730783209 [/CODE] Local doesn't matter.
  • You have one less table lookup doing that so obviously it's faster, though you have absolutely no reason to define it as a global.
  • [QUOTE=ralle105;34894534]You have one less table lookup doing that so obviously it's faster, though you have absolutely no reason to define it as a global.[/QUOTE] Use it in all files?
  • Then you might as well use love.graphics. If you're gonna make shortcuts to globals at the top of your file they should be locals, it's just good practice.
  • You shouldn't use single letter variable names. It looks messy as fuck and has no advantage over normal variable names. You should use an editor with auto-complete if you can't be bothered to type it out. Micro-optimizations like that are also pretty much useless. Yeah, it might run even a couple of microseconds faster, but would anyone even notice that? All that they do in the end is just clutter up the code. [editline]27th February 2012[/editline] Sorry if I came out as rude - wasn't my intention.
  • I suggest reading these and becoming familiar with the Lua syntax and naming conventions. [url]http://lua-users.org/wiki/LuaStyleGuide[/url] [url]http://www.lua.org/pil/[/url] Being a good coder means knowing these naming conventions. Programming in Lua is also a really good read and important to know as a Lua coder. Lua isn't a hard language to know and understand, but it takes time to learn and remember common conventions and practices. This is pretty important for all languages. I'm not going to enforce this in this event, but don't be an asshole and write terrible code for others to fix. Nobody wants to spend their 24 hours with the code fixing shit you did wrong. [editline]123[/editline] [B]Note: I am not taking minecraft into consideration here. Minecraft's code is god awful and the game, in a technical standpoint, is terrible.[/B] For example, look at Notch. He is a bad programmer. Why? He knows computer science and understands common practices. A lot of his code is efficient and runs fast. Whats wrong with that? He doesn't know variable naming conventions. Here's an example of code in Catacomb Snatch (a game he made in a weekend for the Mojam): [code] int xy = xx*yy; [/code] What the fuck does that mean? We have no clue what [I]xx[/I] or [I]yy[/I] is or holds. A better name for these could be [I]deltaX[/I] and [I]deltaY[/I].
  • [QUOTE=i300;34895599]Here's an example of code in Catacomb Snatch ([b]a game he made in a weekend for the Mojam[/b]): [code] int xy = xx*yy; [/code] What the fuck does that mean? We have no clue what [I]xx[/I] or [I]yy[/I] is or holds. A better name for these could be [I]deltaX[/I] and [I]deltaY[/I].[/QUOTE] to be fair, you don't make a game in a weekend by writing clear, relatively long variable names
  • [QUOTE=i300;34895599]I suggest reading these and becoming familiar with the Lua syntax and naming conventions. [url]http://lua-users.org/wiki/LuaStyleGuide[/url] [url]http://www.lua.org/pil/[/url] Being a good coder means knowing these naming conventions. Programming in Lua is also a really good read and important to know as a Lua coder. Lua isn't a hard language to know and understand, but it takes time to learn and remember common conventions and practices. This is pretty important for all languages. I'm not going to enforce this in this event, but don't be an asshole and write terrible code for others to fix. Nobody wants to spend their 24 hours with the code fixing shit you did wrong. [editline]123[/editline] For example, look at Notch. He is a bad programmer. Why? He knows computer science and understands common practices. A lot of his code is efficient and runs fast. Whats wrong with that? He doesn't know variable naming conventions. Here's an example of code in Catacomb Snatch (a game he made in a weekend for the Mojam): [code] int xy = xx*yy; [/code] What the fuck does that mean? We have no clue what [I]xx[/I] or [I]yy[/I] is or holds. A better name for these could be [I]deltaX[/I] and [I]deltaY[/I].[/QUOTE] For projects like these okay, but for private projects, what if you don't [B]want[/B] others to read your code?
  • [QUOTE=icantread49;34895850]to be fair, you don't make a game in a weekend by writing clear, relatively long variable names[/QUOTE] If you're working on an open source project that you may or may not show off to companies you apply to work at, I would make my code as clean and good looking as possible. Maybe Notch doesn't care anymore because he has a solid job at Mojang, but when collaborating with other people (like he did. Catacomb Snatch was a collaboration between Notch and Jeb) I would make my code clean and readable. For me, programming is about having fun but also writing good code that I can show off. I want to know how to write good code and be persistant about writing good code. If this is going to be my career I want to be damn good at it.
  • [QUOTE=Darkwater124;34895904]For projects like these okay, but for private projects, what if you don't [B]want[/B] others to read your code?[/QUOTE] It will be hard for your to switch. What if you need help and you need to show your code? Or what if you decide that you do want to release it open source? Why make it hard on others(or yourself, if you end up changing it later)?
  • [QUOTE=i300;34895599]For example, look at Notch. He is a bad programmer. Why? He knows computer science and understands common practices. [B]A lot of his code is efficient and runs fast.[/B][/QUOTE] Uh, I think you might be thinking of someone else there...
  • [QUOTE=Lexic;34896218]Uh, I think you might be thinking of someone else there...[/QUOTE] I'm not really talking about or considering minecraft. Minecraft's code is god awful. It got too big and became tangled and convoluted. His smaller weekend games run pretty fast and well.
  • [QUOTE=Darkwater124;34895904]For projects like these okay, but for private projects, what if you don't [B]want[/B] others to read your code?[/QUOTE] Don't show them. Additionally, delete the code when done. No need to write in ass-backwards naming conventions just in case someone happens to run away with your laptop and starts reading your source code. Ridiculous.
  • I've kinda run out of time and motivation for the day after a really busy day so I've kinda implemented some really cool stuff for the future to allow for objects in the game to interact with but at the same time have left them half complete. I'll see if I can gain any energy to finish them a little more, but I guess the future people will just need to hack on top of what I've done.
  • [QUOTE=gparent;34896296]Don't show them. Additionally, delete the code when done. No need to write in ass-backwards naming conventions just in case someone happens to run away with your laptop and starts reading your source code. Ridiculous.[/QUOTE] We're talking about LOVE here.
  • [QUOTE=Darkwater124;34896728]We're talking about LOVE here.[/QUOTE] How does that change anything?
  • I know we already went over this whole _g thing, but for those who are still curious about optimizing Lua, This is actually pretty good. [URL]http://www.lua.org/gems/sample.pdf[/URL] an excerpt: [code] for i = 1, 1000000 do local x = math.sin(i) end runs 30% slower than this one: local sin = math.sin for i = 1, 1000000 do local x = sin(i) end [/code]
  • [QUOTE=Lexic;34897073]How does that change anything?[/QUOTE] Let's have a bundled .exe: [IMG]http://new.tinygrab.com/7cfbd5178338da8c513e9a286550357c54d90c24b0.png[/IMG] And open it with WinRAR: [IMG]http://new.tinygrab.com/7cfbd51783eafbc2649540fed0f37cc41eb51943b5.png[/IMG] Now this is a "compiled" LOVE game, including needed dll's. The .exe has been made by copying the .love file to the love.exe. Now let's open that one with WinRAR. [IMG]http://new.tinygrab.com/7cfbd5178379ef878c540390b9b86cb9073c9954a8.png[/IMG] There you have it, all source files are visible. That's the disadvantage of LOVE, it doesn't get compiled. So it's easier to (for example) upload fake scores to an online scoreboard, which means more people are gonna do such stuff. Now this is just an example, but there are many people who just don't want others to (easly) read their source. I'm one of those.
  • [QUOTE=Darkwater124;34897369]There you have it, all source files are visible. That's the disadvantage of LOVE, it doesn't get compiled. So it's easier to (for example) upload fake scores to an online scoreboard, which means more people are gonna do such stuff. Now this is just an example, but there are many people who just don't want others to (easly) read their source. I'm one of those.[/QUOTE] Oh, you mean public projects where you wish to keep the source private. Private projects are ones that you don't give to anyone. In any case, obfuscation should be something that happens later, not something you do while you write the thing.
  • [QUOTE=Lexic;34897429]Oh, you mean public projects where you wish to keep the source private. Private projects are ones that you don't give to anyone. In any case, obfuscation should be something that happens later, not something you do while you write the thing.[/QUOTE] Well, I'm used to it and I'm the only coder, so I don't see any problems.
  • Hi, I'm a horrible and lazy person. Have fun. [url]http://filesmelt.com/dl/FP.zip[/url]
  • [QUOTE=Darkwater124;34897465]Well, I'm used to it and I'm the only coder, so I don't see any problems.[/QUOTE] God damn. How can you be so persistent about continuing your bad habits? Can you really not see how it's a bad thing to do? Screw "personal projects". It's not called a habit for no reason.
  • [QUOTE=Darkwater124;34897465]Well, I'm used to it and I'm the only coder, so I don't see any problems.[/QUOTE] Getting into terrible habits early is a problem if you ever want to get into the professional world. In any case, using short variable names is to obfuscation what ROT13 is to cryptography. A couple of minutes with global find/replace and your code is fully readable. Write it cleanly and then destroy it with things like multiple variable redefinition, abstract stacks and befunged tables.