Page 1 of 1

Source Code: The Game

Posted: Tue Aug 21, 2012 10:54 pm
by Nsmurf
Hello LÖVERS,

Let me present to you, Source Code: The Game

It is a game where you fly around in a spaceship and edit the source code for the game. So without further ado, the instructions:

Movement: WASD
slow down: Q
Select a letter: right click
replace a letter with the selected letter: left click
Update code: Click the update button

NOTE: If you have run this game before, DELETE THE OLD SAVE FILE BEFORE RUNNING IT AGAIN! If you do not, the game will be running 2 instances of main.lua, so the FPS takes a serious hit. (if anyone knows how to make the code do this automatically, please tell me.)

Credits:

Code: Nsmurf (memberlist.php?mode=viewprofile&u=57522)
Music: Readily Available Ketchup By Zanzlanz (http://www.zanzlanz.com/)
Idea: Ninjasmurf

I am glad to hear any advice/criticism about this.

Another note:
I know of the bug where you click above of below the code, but if you find any others, tell me.

And just to finish off the post, a screenshot (it got a bit washed out, but you get the idea) :

Re: Source Code: The Game

Posted: Tue Aug 21, 2012 11:36 pm
by Roland_Yonaba
The concept is original. And way more weird than I expected ... :awesome:
I had some fun, though.

Well, you should consider clean your original code, and use a proper indentation, as it isn't that easy to read the way it is, actually.
Maybe you should avoid saving an edited chunk if it couldn't be loaded properly after hitting the update button.
The game can't be restarted later, yielding an err.

Also, you should enhance the controls. Actually, it is pretty complicated to edit the initial source.
Envision to enable keyboard use.

BTW, the message 'the chunk was not loaded properly' must be splitted into two lines at least, as it doesn't fit in the black box.

How the check did you came up with that idea ?

Re: Source Code: The Game

Posted: Wed Aug 22, 2012 1:26 am
by Nsmurf
Maybe you should avoid saving an edited chunk if it couldn't be loaded properly after hitting the update button.
Wow, i didn't even notice that... Thanks for pointing it out.
Also, you should enhance the controls. Actually, it is pretty complicated to edit the initial source.
Envision to enable keyboard use.
I want to enable keyboard editing, but wasn't exactly sure how to go about it. The only way that i could think of was to get the ascii value of the key that they were pressing, then use some function to turn the ascii value into a character.
BTW, the message 'the chunk was not loaded properly' must be splitted into two lines at least, as it doesn't fit in the black box.
Oh, i was meaning to make that say "Syntax error" instead, because that is the only way that i found out how to get that error, but didn't get around to it.
Well, you should consider clean your original code, and use a proper indentation, as it isn't that easy to read the way it is, actually.
Hehe, yeah. I usually write my code that way, since i don't find it hard to read like that, but it is more standard to indent it, and for a game like this, that's everything.

Thanks for all the feedback,

Nsmurf

Re: Source Code: The Game

Posted: Wed Aug 22, 2012 2:08 am
by Qcode
Nsmurf wrote:
Also, you should enhance the controls. Actually, it is pretty complicated to edit the initial source.
Envision to enable keyboard use.
I want to enable keyboard editing, but wasn't exactly sure how to go about it. The only way that i could think of was to get the ascii value of the key that they were pressing, then use some function to turn the ascii value into a character.
If you get the ascii then you can use string.char(ascii) to turn it into a character.

Re: Source Code: The Game

Posted: Wed Aug 22, 2012 2:31 am
by Roland_Yonaba
Nsmurf wrote: I want to enable keyboard editing, but wasn't exactly sure how to go about it. The only way that i could think of was to get the ascii value of the key that they were pressing, then use some function to turn the ascii value into a character.
Well, I'm make a proposal, but I'm not sure that's the best solution here, but it can work..
You could manage your editor using a regular Lua table.
When you read the whole contents of the main.lua file, you store each single line in a table.
Then you just display all these lines, looping through this table.

Now, editing becomes simple. Whenever a mousepressed event is registered, assuming the x,y position of the mouse at this very moment, we can workout what line is supposed to be edited. This computation should take into account the fact that the lines may scroll (up/down/left/right).
Then all you have to do is catching all keyboards input unicode using love.keypressed, turn them into human-readable characters using string.char, and take into account of specific keys for deleting, line split, etc.
And make advantage of Lua's string library (string.sub will obviously be required a lot, I guess).

You don't have to make a full text editor, only basic stuff is needed here.

Re: Source Code: The Game

Posted: Fri Aug 24, 2012 11:09 pm
by Nsmurf
Thanks for pointing out love.keypressed.

I already do everything else you describe.

The only problem that i see is that i am using wasd keys to move, so you would need to be not pressing movement keys in order to select, but i'll find a way around that. :awesome: