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.

Android / [SOLVED] Learning to Code

Author
Message
AlexSimm
5
Years of Service
User Offline
Joined: 5th Jun 2018
Location:
Posted: 5th Jun 2018 02:49
Hello everyone, long time viewer first time poster.

I am attempting to write a piece of code which will do the following.

Step One: Make a clickable area preferably a circle.
Step Two: Upon user click, within the circle, it will generate a random number between 1 - 3 (if player clicks outside circle nothing happens)
Step Three: Using a nesting if statement assign an action to each random number generated.

Sadly the nesting if statements are giving me a serious migraine. Is anyone able to assist?

Thanks in advance...

Alex

The author of this post has marked a post as an answer.

Go to answer

PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 6th Jun 2018 19:35
Hey,

have you thought about using Select / Case?


PSY LABS Games
Coders don't die, they just gosub without return
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 11th Jun 2018 14:02
This post has been marked by the post author as the answer.
Without seeing any code, it is difficult to determine what you are doing wrong. If you are trying to pick a different action based on the random selection, you should use one of the following structures.

Alternatively, you can use Select/Case

The nice thing about Select/Case is that you can combine results. So if choice 1 and 3 have the same outcome, you can do
Case 1, 3
DoSomething()
EndCase
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 16th Jun 2018 12:12
Quote: "The nice thing about Select/Case is that you can combine results."


yes, its very helpful, I also like you can fold case sections, unfolded if-else-endif make messy code and hurt my eyes! lol
Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 29th Jun 2018 12:18
You can alternatively structure the options in Types and iterate beween them. This avoids excessive conditionals.

Login to post a reply

Server time is: 2024-04-19 08:52:43
Your offset time is: 2024-04-19 08:52:43