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.

AppGameKit Classic Chat / Game menu Help

Author
Message
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 1st Dec 2021 07:18
So first running my game the menu starts no problem, running it with a do loop.

Then I delete everything and go to the game loop.

But when I die and loose all my lives I go back to the menu.

Everything deletes and the menu opens back up but nothing works as if I am not in the menu loop.

Somehow It does not change to go back to the menu loop it just loads in the images and other stuff.

pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 1st Dec 2021 08:24
I suppose if you want help you should show the code. So that other forum residents can find a bug in it. We are not psychics and cannot see the code not shown.

I myself am busy with my game.
But if your program is not complicated, then I can find time for you.
programming is a hobby, not a job.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 1st Dec 2021 10:02
As pavelman said, it is impossible to help find issues with your code unless you show it.
See here for an example of how to ask for help with code.

What I can offer (if it helps) is to show you my standard game loop.
The code below (and other code irrelevant for this discussion) is automatically inserted into the main.agc file whenever I start a new project. It is my standard main game loop.
The functions are all empty and need fleshing out but it is a great starting template that might be of use to you.
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 1st Dec 2021 10:57
This is a hat from my game that I am currently making.


And after long torment of searching for errors, I switched to this form.
Separate cycle menu
The game is a separate cycle.
programming is a hobby, not a job.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 1st Dec 2021 11:11
Wait for it.

There's a lot of GOTO haters about to jump on the thread ....
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 1st Dec 2021 18:31 Edited at: 1st Dec 2021 18:32
Hi Guys

I just noticed that if I run my menu in the main game loop and just call if menu=1 or if menu=0 then there is no problems.

Sorry to much code to show or post in this problem.

I was Gosub to the menu loop and I believe this was the problem.

Quote: "There's a lot of GOTO haters about to jump on the thread "


I never understood why, It is a built in function that we use for a reason, nothing wrong with GOTO .
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 1st Dec 2021 20:47 Edited at: 1st Dec 2021 21:05
Quote: "I never understood why, It is a built in function that we use for a reason, nothing wrong with GOTO .
"


You are correct, but the GoTo command even though it is always a part of a language, using it will cause the code to get lost. Meaning you always have to say

GoTo here:


here:

GoTo there


there:

GoTo over here

over here:
GoTo here


When you could say

GoSub here

here:
There()


Function There()

over here()
Return
EndFunction


GoTo code you will get lost and it gets messy
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex

No one cares how much you know until they know how much you care.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 1st Dec 2021 20:59
Quote: "GoTo code you will get lost and it gets messy"


Not unless you are using it for a good reason

If you use it correct or your program runs off of it then you should use goto

or there is gossub
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 1st Dec 2021 21:09
Quote: "Not unless you are using it for a good reason

If you use it correct or your program runs off of it then you should use goto

or there is gossub "


Small program you will probably not get lost, but large multi #include file programs you will probably get lost. I did
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex

No one cares how much you know until they know how much you care.
Abiz
12
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 1st Dec 2021 23:16
Here is my main game loop; Has been used since 2017 and works fabulously.
Every navigation item is an independent function that does a deletetextall() and deleteSpriteall().
Clean in and out.

GOTO's are fine until you hit a return by accident.... Your stack is now corrupted.
GOTO is a leftover from Assembler and yes, when you program an if else endif , the final machine code will still have JMP's (assembler version of GOTO).

However, it makes for code that can be a total bitch to debug when you have to. (my games typically have over 20,000 lines of code)

Good luck with your work.
James

Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 2nd Dec 2021 02:42
Quote: "Small program you will probably not get lost"


Yes of course, I do not recommend using them for large games but for other things there good to use.

Quote: "GOTO's are fine until you hit a return by accident.... Your stack is now corrupted."


Yes lol, whoops, then you spend hours and even days trying to find the problem.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Dec 2021 07:01
GOTO is sloppy, there's no need to use it. Properly structured code won't need it.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 3rd Dec 2021 04:12
Quote: "nothing wrong with GOTO ."


Mmmm yeah, I like a nice bolognaise ...

GoTo's invite and lead to spaghetti code if not used properly, it is a relic from 1970's and has no place in modern functional programming languages!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
pavel_sv_1982
11
Years of Service
User Offline
Joined: 9th Apr 2013
Location: Russia
Posted: 3rd Dec 2021 08:45 Edited at: 3rd Dec 2021 09:19
Quote: "Mmmm yeah, I like a nice bolognaise ...

GoTo's invite and lead to spaghetti code if not used properly, it is a relic from 1970's and has no place in modern functional programming languages!"


Well, as if this command is present in machine languages. It's like the foundation of the language.
Go to this address.
Without this machine code, there would be no computers that we know.

therefore you must respect and honor this command "GoTo", and you are trying to bury it.
programming is a hobby, not a job.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 3rd Dec 2021 11:52
So do you have a mechanical CPU?, Did you make that post from a Turing machine?, if we are going to respect and honour tech from the past why are we using silicon and not steel?

Modernity ......

It served its place in a by-gone era but like I said "has no place in modern functional programming languages", key emphasis on the functional

I did Basic on the Atari 400 and C64 I know all about GoTo, that was 35 years ago, we have functions now ......



Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Dec 2021 13:41
By that logic we should all be writing code directly in binary...
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 3rd Dec 2021 16:23
yes, on stone tablets


Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-11-21 12:29:37
Your offset time is: 2024-11-21 12:29:37