Source Code: The Game

Show off your games, demos and other (playable) creations.
Post Reply
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

Source Code: The Game

Post 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) :
Attachments
Screenshot
Screenshot
SC1.JPG (62.73 KiB) Viewed 3461 times
SourceCodeTheGame.love
Source Code: The Game
(4.06 MiB) Downloaded 251 times
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Source Code: The Game

Post 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 ?
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

Re: Source Code: The Game

Post 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
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
User avatar
Qcode
Party member
Posts: 170
Joined: Tue Jan 10, 2012 1:35 am

Re: Source Code: The Game

Post 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.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Source Code: The Game

Post 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.
Last edited by Roland_Yonaba on Fri Aug 24, 2012 11:26 pm, edited 1 time in total.
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

Re: Source Code: The Game

Post 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:
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest