Is it possible to load a game at certain points

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
ShadowTower
Prole
Posts: 6
Joined: Mon Apr 29, 2019 12:21 am

Is it possible to load a game at certain points

Post by ShadowTower »

Hi. I just wanted to know if there is a way to make states of a pre existing game so I could load certain menus without going through others. I want to make a modification of Sharp Objects Panel-Attack: https://github.com/sharpobject/panel-at ... HvUlFmYmeh
As you can see, the look of the game is kind of plain, like the font and menus, so I wanted to fix it up with some menu graphics and sounds, but another thing I really want to do is make a custom menu that will open certain menus in the pre existing game and not others. I also want to not include the pre existing characters and instead add a mode where custom characters are batteled in a certain order, like a story mode.
I'm new to lua but I'm learning a lot of it trying to do this. So my question is, how can I create a menu so that when certain things are selected it will load say the difficulty/speed screen in the original game? And how could create a mode that loads certain puzzles in a certain order?
I know this might be big question, and I am planning on studying more lua, but I think its really valuable to know some pro advice. :3
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is it possible to load a game at certain points

Post by pgimeno »

Hello, welcome to the forums.

Is it possible? Yes, of course it is. You can keep track of the state of a program (game in this case) in certain variables, to restore them and resume at a given point later. State is everything. If you restore every piece of state the same it was, it will then resume at the same point and continue with what it was doing. That's, for example, the principle behind Thrust II Reloaded's save/load feature (see my sig); I keep all state relevant to the game in a single variable, e.g. ship and enemy position, direction, velocity, timers... so that it can restart at the very same place and continue as if nothing happened. That's also the principle used by emulators that allow saving and restoring: they dump the whole memory, registers and other possible state to a file, so they can restore it later.

One problem you're facing is that it's not your code, therefore nothing ensures you that it was designed in a way that facilitates making these changes. You'll need to study the code carefully, or perhaps it's better if you start your own from the ground up, not because the code is bad (I haven't even looked, so I can't know how good or bad it is), but because spending time studying someone's code can sometimes be more time consuming than writing it from the ground up with your own methodology, structure and ideas. I don't know if that will be the case, you'll have to check yourself.
ShadowTower
Prole
Posts: 6
Joined: Mon Apr 29, 2019 12:21 am

Re: Is it possible to load a game at certain points

Post by ShadowTower »

Well, I know that there are actually diffrent ways of making states like HUMP and several other libraries. But I know it's also just possible to do it in a LUA editor itself. The games code uses lots of diffrent lua files, like main.lua, mainloop.lua, and I kind of sort of make sense of what is going on in these, but now that you said it's possible to store the state of the game in a variable where do you suppose, in each code, a line like this would go?
Just to provide a little blueprint of what I'm going for, I'm going to show everyone some mock-up images of what I would like to do with the project;
This is the menu in the original game. As you can see, there are several diffrent things listed.
This is the menu in the original game. As you can see, there are several diffrent things listed.
2P.PNG (11.11 KiB) Viewed 4977 times
This is a sample menu I made. As you can see there are less things listed than the original menu. Let's say we select 2P Mode
This is a sample menu I made. As you can see there are less things listed than the original menu. Let's say we select 2P Mode
Sample.png (185.34 KiB) Viewed 4975 times
2P Mode should lead us here.
2P Mode should lead us here.
2P2.PNG (5.7 KiB) Viewed 4975 times
ShadowTower
Prole
Posts: 6
Joined: Mon Apr 29, 2019 12:21 am

Re: Is it possible to load a game at certain points

Post by ShadowTower »

I also wanted to show off my concept for the graphics and animations.
Let's look further at 2p mode. Here is a crude sketch of how I would want the 2p screen to look;
It would be intresting to add character animations that react to what's happening in the puzzle
It would be intresting to add character animations that react to what's happening in the puzzle
20 characters.PNG (135.3 KiB) Viewed 4974 times
This image shows off some ideas of how I would like the layout of the puzzle screen would look.
This image shows off some ideas of how I would like the layout of the puzzle screen would look.
PUZZLESCREEN.png (117.73 KiB) Viewed 4974 times
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is it possible to load a game at certain points

Post by pgimeno »

Well, I'm a bit confused now as to what the question is.

In the first post, I got the impression that you wanted to resume the puzzle at a certain point.

In your second post, however, you seem to imply that what you're trying to do is a multi-level menu, where each selection leads to another submenu.

Can you please clarify?
ShadowTower
Prole
Posts: 6
Joined: Mon Apr 29, 2019 12:21 am

Re: Is it possible to load a game at certain points

Post by ShadowTower »

Well, yes actually, I did want to do a sort of multi-level menu. You see, what I'm trying to do is sort of build a game around this Panel-Attack code, in other words make it appear more like a custom game but use the code of the original. I want to utilize the menu and engine of the game, but give it it's own "shell" I guess you could say. I guess the question
is how I would be able to make a custom menu "around" the original one, where the options on screen may lead or not lead to the options in the original code. I like all the settings of the original game, but my issue is all the features like "Endless Mode", because I don't want the puzzles with the Panel de Pon or Mario characters to be shown, I want to create my own characters for the puzzles so it'll look like it's own game. Like say, if someone were to play the game, there would be a "Championship" mode instead of the "Endless" mode so players would not see the screen where all the Classic sets are listed but instead be lead to a diffrent mode or screen where those settings are not there.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is it possible to load a game at certain points

Post by pgimeno »

OK, sorry, I misunderstood. I can't give you advice on how to implement what you want, because there's no general way; it depends on how the code is written. In this case, I've taken a cursory look and found the program and data flow confusing. I would need to dedicate a few hours to study it, and that's somewhat farther than I'm willing to go.

If no one else wants to chime in, I'm afraid your options are to either study it well and try to implement the changes on your own, or write your own version with an organization that is prepared from the ground up to have submenus and the features you want.
ShadowTower
Prole
Posts: 6
Joined: Mon Apr 29, 2019 12:21 am

Re: Is it possible to load a game at certain points

Post by ShadowTower »

Alright. I have been giving the code a great deal of study already, (It does look confusing) so I guess it's really a matter of figuring out why certain things are written the way they are and where to place certain things. I know it seems kind of complicated, but the reason I decided to ask is because I think that being able to load the code at a certain state, or in this case, at a certain sub-screen, is probably the best way to work around the code, and I figure that most of the members on this forum are familiar with these methods, but I see what you mean about it really being a matter of studying the games script. However, some things I feel like that I could do is test the codes for Love which write data, like type love.filesystem.write into some of the games codes. Right now my aim would be to 'record' a certain sub-screen to a state file, then tell the code to load that file when a certain menu option is selected. I think the problem with this though is not knowing which variables to store in the file. So, I guess if anybody else wanted to chime in, they could provide some input on which state methods work best or which ones are convenient and they like using in their projects, so that I could try experimenting with them.
User avatar
4vZEROv
Party member
Posts: 126
Joined: Wed Jan 02, 2019 8:44 pm

Re: Is it possible to load a game at certain points

Post by 4vZEROv »

For what I can see everything draw are pushed into gfx_q by functions like gprint, grectangle ~l.72 (graphics.lua).
All in game menu are pushed line ~l.339 (graphics.lua).

I believe it's here where you want to draw some stuff.
ShadowTower
Prole
Posts: 6
Joined: Mon Apr 29, 2019 12:21 am

Re: Is it possible to load a game at certain points

Post by ShadowTower »

Oh, I see. Do you mean this line is for the game menu in graphics.lua?:
draw(imgs.left, draw_x, top_y, 0, 1, height*16)
draw(imgs.right, draw_x+16*(width-1)+8, top_y, 0, 1, height*16)
draw(imgs.top, draw_x, top_y, 0, width*16)
draw(imgs.bot, draw_x, draw_y+14, 0, width*16)
draw(imgs.topleft, draw_x, top_y)
draw(imgs.topright, draw_x+16*width-8, top_y)
draw(imgs.botleft, draw_x, draw_y+13)
draw(imgs.botright, draw_x+16*width-8, draw_y+13)
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests