Making a Game

Discussion in 'Other Games' started by FlyingIsOP, Jan 5, 2017.

  1. FlyingIsOP

    FlyingIsOP Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Jul 20, 2013
    Messages:
    517
    Trophy Points:
    27,905
    Gender:
    Male
    Ratings:
    +208
    My friend and I are going to be making a game in Java pretty soon. I would love to hear your suggestions as to what it should be.
    Just keep in mind it will be:
    2D
    Very simple
    Not very good, it's the first time we are doing this.

    Of course you all will be able to try it out if you like and I'm not sure if it will be done anytime soon but we'll see! Thanks you guys! :)
     
  2. JerichoKross

    JerichoKross Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️

    Joined:
    Dec 23, 2013
    Messages:
    458
    Trophy Points:
    21,290
    Gender:
    Male
    Ratings:
    +97
    If you are new to programming, I suggest looking into the LOVE2D framework. All your code can be written in Lua, which is very easy to learn. The framework is open source, runs on LuaJIT and is cross-compatable with Windows, Mac, Linux, and mobile. It is possible to run in a browser, but with a little finesse. Anyways, go check it out and see what you think. ;)
     
  3. FlyingIsOP

    FlyingIsOP Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Jul 20, 2013
    Messages:
    517
    Trophy Points:
    27,905
    Gender:
    Male
    Ratings:
    +208
    OK thanks I'll check it out!
     
  4. Expipiplusone

    Expipiplusone Builder
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Sep 13, 2014
    Messages:
    1,592
    Trophy Points:
    37,590
    Gender:
    Male
    Ratings:
    +778
    Arw :cat: I've worked with Lua for a couple months a few years ago... I recall it being quite easy to learn, despite it has a few odd unexpected features. Here's a part of the development notes I wrote for that project, though I'm not sure they're up-to-date (last time I edited them it was 6 Dec 2012):
    USEFUL NOTES ABOUT LUA

    Lua is very powerful and, despite it lacks some costructs, you soon realize that you don't really need those constructs.

    For instance, let's say that you want to write some code that in C++ would be:
    > foo = (condition) ? (expression_if_true) : (expression_if_false);
    Well, in Lua you just write:
    > foo = (condition) and (expression_if_true) or (expression_if_false)
    It works because of lazy evaluation of logical operators even when expression_* is not boolean :)
    After you understand how to use it, it will prove waaaay more powerful than the ternary operator ?:

    Similarly, 95% times you use a switch-case, you don't really need it if you have tables:
    > http://lua-users.org/wiki/SwitchStatement

    But it's not all roses and flowers: Lua has two big misfeatures and you MUST know them if you're going to write Lua code.

    1) The default scope is global. GHHAAAAAAAGGGHHH! Why on Earth??

    2) Arrays start from 1, not from 0. Well, this makes slightly more sense (in comparison).

    Behind (2) there is a historical reason, being Lua descended from Sol (Simple Object Language).
    But I still fail to find a reason behind (1). Anyway, in order to declare a local variable, you just have to put the keyword "local" before. If you're afraid that you could have wrongly declared a global variable by mistake (it's easy to forget to write the "local" keyward sometimes), you can just call in a shell:
    > luac -o /dev/null -l na62_dissector.lua | grep SETGLOBAL
    It should output nothing. If it prints something like this:
    > 75 [42] SETGLOBAL 1 -30 ; wrong_global
    It means that you declared a variable called wrong_global in line 42.
    Actually, that command is also useful to pre-compile the script without running it in wireshark, in order to find the most obvious errors.
     
  5. JerichoKross

    JerichoKross Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️

    Joined:
    Dec 23, 2013
    Messages:
    458
    Trophy Points:
    21,290
    Gender:
    Male
    Ratings:
    +97
    Regarding globals, you can use setfenv. I honestly don't use it often though... As long as your always thinking in terms of scope, it's not difficult to create an entire game without any globals. You can create a local table in one file and assign it to a local variable in another with require(). For example:

    potatoFile.lua
    Code:
    local potatoTable = {
        remaining = 100 --percent
    }
    
    function potatoTable:eat()
        self.remaining = self.remaining - 10
    end
    
    return potatoTable
    
    main.lua
    Code:
    local potato = require 'potatoFile'
    
    print(potato.remaining) -- 100
    potato:eat()
    print(potato.remaining) -- 90
    
     
    • Informative Informative x 1
    • List