Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / "Hello game Creators" 18 years of animation experience does NOT prepare you for coding.

Author
Message
BaoRyn
User Offline
Joined: 3rd Mar 2021
Location:
Posted: 4th Mar 2021 03:06
Hi, My name is Byron, BaoRyn in online games. I'm an animator and 3d modeler with most of my experience in rapid prototyping and aerospace engineering.

So long story short, Picked up the APG bundle pack and the hands on books last week. Thought this looks great to learn coding, Proceeded to watch the tutorial videos and go over as many of the forum posts that I can find and still think I'm missing something major, aside for many years experience in coding. Or maybe I'm just getting to old to see the obvious. All the tutorials I'm finding are in single scene one shot games, no levels.
I have 7 scenes with different sprites/ same sprites and I cant find anything that allows me to press a button on the first scene to go to any of the other 6 then while on them hit a go back button to start the first again. I tried using the virtual button to do this but if I have a virtual button on scene 2 then I get an error. I
know and have read that they are finicky but seriously......... I was hoping someone could help with a tutorial or code for a simple go to scene 2,3,4,5,6 buttons with a return to scene 1 button on each of those pages/scenes. Or something on Changing/ implementing new levels. Any help would be awesome, thanks in advance.
PartTimeCoder
AGK Tool Maker
6
Years of Service
User Offline
Joined: 9th Mar 2015
Location: Suffolk UK
Posted: 4th Mar 2021 16:18
Implementing scene switching highly depends on your project structure but its really as simple as grouping the sprites for scene 1 in an array_scene_1 and delete/hide the sprites in that array when you want to close the scene.

and it sounds like you are not making use of error checking functions, without seeing your code its hard to guess but my stab in the dark is you remove a virtual button with an index but your main loop is checking for events for that button???

look at GetVirtualButtonExists().
BaoRyn
User Offline
Joined: 3rd Mar 2021
Location:
Posted: 5th Mar 2021 16:54 Edited at: 5th Mar 2021 17:02
Hey thanks for the response. I'm definitely not making use of error checking functions....... don't know what they are. I have used the virtual button commands with little success but I did go back through the starter videos in this forum with a little better understanding and think I found a solution in the GoSub command. I hope this helps if anyone else is in my situation.
So I'm making a crew/ character manager with different scenes for each character, with functions on each one and a Ship scene to act as the menu. I found that if I made a .AGC file for each scene and label them , that I could use the GoSub to call what I want and when,
so this:


not sure if this is a standard way of doing things but it seems to work for me so far, now if there is a way to save progress/ edits in the app that would be great.

[MOD EDIT] Please use code tags if you want to display code on the forum. I have done it for you this time.
n00bstar
17
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 7th Mar 2021 15:07 Edited at: 7th Mar 2021 15:15
I don't use scenes so I don't really know if this applicable.. but it seems to me your code would benefit from using Select instead. Something like:



I would also advise against using Gosub the way you are doing because you basically have a lot of them nested into one another. A Gosub command goes to your sub label, and then returns where it was called from once the code is executed. So when you're calling a Gosub that goes somewhere with another Gosub, and to yet another place with another... you quickly lose sight of where your code is at. I suggest you create functions for stuff like what you're doing. There's no need to rewrite the same piece of code for every situation in the game. Write it once into a function, and call that function instead.

Another coding habit you should try to get into right now is to only have one loop. I see you your code is made of multiple loops and this is going to make your life very complicated sooner than later. Using Select is also a good idea here. It could for example be something like this:



As your program gets bigger and more complicated, you will find that you can get your head around the mass of code more easily if all things are run from a central loop.

Oh.. also.. comments are your best friends. Use them.. everywhere! Even for stuff that seems obvious. What's obvious now won't be obvious later when you need to update something that was written two months and 15000 lines of codes ago
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
BaoRyn
User Offline
Joined: 3rd Mar 2021
Location:
Posted: 7th Mar 2021 18:17
@n00bstar, that looks awesome, looks a lot cleaner than what I was doing, would never have thought of it, but like I said, I literally just started last week, so not sure how exactly to implement it. Any possibility to pick your brain a bit more. For instance, inside your loop. what dictates the page/scene your on? I can see how to set up the characters in the select portion but I'm not seeing how to connect them. For further explanation, I'm trying to launch into a Ship scene where i can then select a crew member to go to their crew manager, save, then go back to the ship to select a different crew member. Not so much a game really but more of a utility for a table top game. So far I've been able to get the scenes to switch properly, get the status pips to turn on and off and the return to ship button works but... when I try to set a character image, it sets perfectly but breaks all the button functions. Would that be the issue with the GoSubs you were talking about?
code for the captain scene

The code is basically just taken from the hands on book and the App Game Kit commands page with some modifications to fit my need.
I promise I am learning. Ill get this sooner or later.
n00bstar
17
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 7th Mar 2021 20:34
Quote: " Any possibility to pick your brain a bit more. "


Sure thing. Come to the official AppGameKit discord and hit me up in private chat, it'll be much simpler (and much less spammy for the forums) to answer your questions....and we can trade code files back and forth. I've got the same nickname over there.
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
Scraggle
Moderator
17
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 7th Mar 2021 20:59
Or continue here so that other newcomers can benefit from the help

Login to post a reply

Server time is: 2021-04-10 15:52:12
Your offset time is: 2021-04-10 15:52:12