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 / boolean and enum types...

Author
Message
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 10th Mar 2017 19:38
...are both sadly missing from AGK.

I've been away for too long I realize - just started today to make a frontend in AppGameKit for a backend done in Go, which I've been tinkering with now for a few months.

Anyhow, I soon re-discovered that my dear old friends, the bool and enum are MIA in AGK. Both are very dear friends, and I feel terribly lonely without them.

Bool is so nice for flags, and use in conditionals. No need for the comparator, just plop it in and done, it's either true or false by its' very nature.

And for control-structures the enum is my go-to guy. Saves the mess of selecting on obscure numeric values or through the slowness of comparing strings. Enums make code easier to read, and cuts the potential for bugs.

Any chance me and my friends can get together in AppGameKit?
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 10th Mar 2017 20:41
Are you talking about Teir1 or Tier2. Elaborate
The coffee is lovely dark and deep,and I have code to write before I sleep.
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 10th Mar 2017 21:34 Edited at: 10th Mar 2017 21:38
Tier 1 obviously - in Tier 2 you got the full force and bewildering options of C++ rev.11. Why I use Go for backend stuff, I just can't keep up with C++ anymore

(edit and off topic: in Go v1.8 there was an entire new feature; sort a slice. That was it. I love it )
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 10th Mar 2017 21:43
Quote: "Go v1.8"


Is this a programming language?
The coffee is lovely dark and deep,and I have code to write before I sleep.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 11th Mar 2017 01:24
You can use constants in place of enum, it's not exactly the same, but usually close enough.

One of my standard include files uses constants to enum a keymap:

#CONSTANT TRUE 1
#CONSTANT FALSE 0
#CONSTANT ENUM_KEY_W 87
#CONSTANT ENUM_KEY_A 65
#CONSTANT ENUM_KEY_S 83
#CONSTANT ENUM_KEY_D 68

etc
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 11th Mar 2017 01:45
Quote: "Is this a programming language?"


Yes. Though you won't have much luck googling it - which is a bit ironic considering it was developed by Google, and still under their curation even-though it's been open-source since 2010 and got to v1.0 in 2012. So to make it more 'search' friendly, it's also commonly known as Golang. Which you can google and get straight to the mother-lode as it were.

Where AppGameKit make frontend clients and games easy - in relative terms - Go do the same for backend. Only with no compromises. It got nearly the speed of C++ seeing as it compiles to static native binaries. And for making multithreaded apps, just about nothing comes close in ease of use.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Mar 2017 05:06
I believe any number other than 0 will evaluate as true. I forgot who, but someone explained to me why the only data type in AppGameKit is floats and integers. It has something to do with how other data types are allocated in 4-byte blocks on mobile devices, thus a boolean would still take up 4 bytes anyway. Whether that's true or not I'm not certain, it's been awhile since I heard it.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 11th Mar 2017 07:08
Quote: "I believe any number other than 0 will evaluate as true."


Yes, I know how it works - I'd still like to have the types though. You can't flip an integer, you can with a bool. You can't dispense with the comparator using an integer, you can with a bool.

'If isTrue then...' reads a bit different than 'if isTrue = 1 then...'

'isTrue = not isTrue' is more readable than 'if isTrue = 1 then isTrue = 0 else isTrue = 1 endif'

Trying to assign anything but 0 or 1 (true or false) to a bool will throw an error - with an integer you can scratch your head and go on a bug-safari for hours before it dawns on you that by some chance you flag-integer have somehow gotten to 2 - or higher - and always read as true.

Workarounds work, but they are still workarounds
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 11th Mar 2017 07:35 Edited at: 11th Mar 2017 07:40
Pretty sure this works without issue:



and is basically equivalent to:

http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 11th Mar 2017 23:26
This should work fine as a replacement for booleans:

#constant false 0
#constant true 1

bVar=true //will be declared as an integer, but we can treat it like a bool

bVar = 1-bVar //flips it

If not bVar then print("false")
bVar=1-bVar
If bVar then print("true")

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Mar 2017 08:31
enum simulation

AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 14th Mar 2017 09:10
Quote: "...are both sadly missing from AGK"

So not missing, just require using the tools available.
Signature removed by mod because it's larger than 600x120... please resize and try again.
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 14th Mar 2017 14:16 Edited at: 14th Mar 2017 14:31
Quote: "So not missing, just require using the tools available."


No. missing - but there are workarounds that offers nearly the same functionality, but not quite. If a variable can have more than two values, it is not a boolean. And enums just do not exist in its' proper implementation where they got intrinsic functionality with no explicit assignment of value.

For instance in C/C++ I use enums for control structures like so:



Simplified of course, all the fluff not needed to make the point deleted. Enums are not holders of value, but a user defined value in and by themselves. In fact, you could call a bool a standardized enum of two - true or false. Allthough, if one want to be nitpicky, those are just aliases for 1 and 0 - and in the C/C++ compiler user defined enums will be given an integer value as well. Which is fine for the machine, that is not the intended target for enums - people are. People programmers prone to producing complexity and interesting logical errors where none need be. Why enums were implemented to begin with. To make code easier to write and more importantly, to read and follow inside our very slow working wetware compiler.

How enums are implemented in Go underscores that an enum have no explicit value:



It do look a bit as the AppGameKit workaround Markus wrote, except there is no need - or possibility - for value assignments. Though in Go you can assign operations and relations to enum definitions, which makes them quite the more powerful a tool than in C/C++ and well out of the scope of functionality I want for them in AppGameKit - which is basically a copy-paste of how they work in C/C++.

Login to post a reply

Server time is: 2024-05-20 18:53:01
Your offset time is: 2024-05-20 18:53:01