Pages: 1
Author Topic: A few things (mostly variables)  (22,378 Views)
Offline (Unknown gender) FroggestSpirit

Member
Joined: Mar 2013
Posts: 79
View profile
Posted on: April 28, 2014, 03:59:12 PM
I've been getting back in the swing of working on my game, and decided to clean up the code (spring cleaning)
I want to store some stuff as constants, like SCREEN_WIDTH, etc but the constants feature didn't seem to work.
My next go to was doing "global var SCREEN_WIDTH=somenumber", and this worked fine
Although then I started getting into the controls "global var KeyPressed[KEY_CONSTANT]=0;" and this had compiling errors.
Is there a way to have an array as a global variable? also, the KeyPressed array I want to make 1 byte per value, how can I do this as well?

On another note, in OGL1, I have a debug menu, it draws a semi-transparent rectangle (white) and inside of it, black text. The text code is after the rectangle stuff, but the rectangle now covers the text (the text worked fine when commenting out draw_rectangle();)

Not sure why, but on my Bubble Bobble clone, after upgrading LGM, some of my sprites were deleted (the resources were still there, but no sub-images). This only applied when loading the EGM. I ended up remedying this by re-importing them, saving as a game maker extension, then reloading that, and re-saving as an EGM. I thought that might want to be looked into.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #1 Posted on: April 28, 2014, 08:10:53 PM
Pretty sure arrays don't work currently, and also not sure why you want to duplicate an array of all the keyboard input, especially when you can just modify the one in Platforms, all you're doing is unnecessarily duplicating the data which already exists. Also, it would be helpful if you would upload the project that encountered the issue, just waiting until after you've gone and fixed everything, does not help me, I have no way of even remotely figuring out what went wrong, why do you people always do this? As soon as something goes wrong, immediately stop, close LGM, back up your project, and report it to me immediately.
Offline (Unknown gender) FroggestSpirit

Member
Joined: Mar 2013
Posts: 79
View profile
Reply #2 Posted on: April 29, 2014, 12:55:00 AM
basically, the global array was going to hold the state of keys, where key would be the array type, and the index would be what key.
Offline (Unknown gender) egofree

Contributor
Joined: Jun 2013
Posts: 601
View profile
Reply #3 Posted on: May 06, 2014, 04:37:41 PM
Quote from: FroggestSpirit on April 28, 2014, 03:59:12 PM
Although then I started getting into the controls "global var KeyPressed[KEY_CONSTANT]=0;" and this had compiling errors.
Is there a way to have an array as a global variable?

Yes, but you have to take in account this :

- Global variables should be declared in objects or with the dot notation in scripts (e.g. global.variable).
- If you use constants (KEY_CONSTANT), declare them as enum in the Enigma settings -> Definitions.
- For arrays, use always var as the type, or use the dot notation. I don't think strongly typed arrays work in ENIGMA right now.

I've taken in account these constraints, and i've successfully used global arrays in my game.
Pages: 1