Documente Academic
Documente Profesional
Documente Cultură
MY SUBREDDITS
POPULAR
-ALL
-RANDOM
ASKREDDIT
-FUNNY
-PICS
-NEWS
-TODAYILEARNED
-AWW
-WORLDNEWS
-GAMING
-GIFS
-VIDEOS
-MOVIES
-SHOWERTHOUGHTS
-MILDLYINTERESTING
-IAMA
-JOKES
-TELEVISION
-OLDSCHOOLCOOL
-TIFU
-LIFEPROTIPS
-PERSONALFINANCE
-SCIENCE
-SPACE
-MUSIC
-EARTHPORN
-PHOTOSHOPBATTLES
-FOOD
-SPORTS
-NOTTHEONION
-TWOXCHROMOSOMES
-EXPLAINLIKEIMFIVE
-FUTUROLOGY
-DATAISBEAUTIFUL
-ASKSCIENCE
-WRITINGPROMPTS
-DOCUMENTARIES
-ART
-UPLIFTINGNEWS
-NOSLEEP
-GETMOTIVATED
-BOOKS
-PHILIPPINES
-HISTORY
-DIY
-LISTENTOTHIS
-GADGETS
-CREEPY
-PHILOSOPHY
-INTERNETISBEAUTIFUL
-ANNOUNCEMENTS
-BLOG
MORE
gamemaker
COMMENTS
Community
Resources
Other
GameMaker is software designed to make developing games easy and fun. It features a unique "Drag-
and-Drop" system which allows non-programmers to make simple games. Additionally, experienced
coders can take advantage of its built in scripting language, "GML" to design and create fully-featured,
professional grade games.
subreddit_guidelines()
Content that does not follow the subreddit guidelines is subject to deletion, so please become familiar
with them.
1. Content must be directly related to GameMaker
2. Content must be in English
3. Content must not be obscene, illegal, racist or offensive
4. Content must not use "click-bait" titles, shortened links, or solicitation
5. Content must demonstrate a previous effort and research before posting and must provide adequate
detailed information
6. Show respect to all users of the subreddit and have patience with other users when providing help
7. Promotional content must contribute to the community
8. Technical support requests are to be directed to YoYo Games Support
9. Content must be appropriately flaired at the time of submission
community()
Conversation
/r/gamemaker sponsors three chat-rooms: IRC, a Discord server, and a Slack team. Join in the
conversation, get help with any issues you might have and connect with your fellow developers!
Scheduled content
Monday Quick Questions Ask questions, ask for assistance or ask about something
Schedule Content Summary
else entirely.
Saturday Screenshot Saturday Share the latest pictures and videos of your game
discussions in r/gamemaker
<>
41 16 comments
1
Solved!Been making a fairly simple quiz game, but have hit a wall. Would love
some help! self.gamemaker
Submitted 2 years ago * by bassman2112
Hey all =)
Sadly I shan't be posting my project file because I'm using JCHTML5, and
don't feel right putting all of his work up for free; but I'll be copying in a lot
of the code I'm using.
So the simple premise: I'm making a game for little kids to help them with
music. They will hear a rhythm being played, and will answer "Yes" or "No"
as to whether it was the one they heard. I plan on doing a more interesting
version of this later where they hear the sound, and then pick one of three
rhythms; but simple for now.
So I have it working with one level - here is the code that makes it work:
First-off, when the room is created, it runs this script (this will later be a
script run by a level selector):
//Initialize variables
global.level_number = 1;
global.correct_answers = 0;
global.question_number = 1;
global.clickable = 1
//Create Questions
global.level1_questions =
ds_list_create();
ds_list_add(global.level1_quest
ions, obj_level1_1);
//And so on
ds_list_add(global.level1_quest
ions, obj_level1_12);
//Randomizes questions
ds_list_shuffle(global.level1_q
uestions);
ds_map_add(global.level_answers
, obj_level1_1, "Yes");
//And so on
ds_map_add(global.level_answers
, obj_level1_12, "Yes");
instance_create(0, 0,
obj_current_question);
instance_create(0, 0,
obj_correct_answers);
if(global.level_answers[?
global.current_question.object_
index] == "Yes"){
//Disables
clicking/extra input
global.clickable = 0;
//audio_play_sound(snd_correct)
//Go to alarm
alarm[0] = 30;
else{
//Disables
clicking/extra input
global.clickable = 0;
global.question_number
+= 1;
//audio_play_sound(snd_incorrec
t)
//Go to alarm
alarm[0] = 30;
}
alarm[0]
ds_list_delete(global.current_l
evel_questions, 0);
This all works wonderfully. It keeps track of score, you can't slam on the
button 100 times and suddenly be at "question 100," et cetera.
The problem I'm having is that I want to have multiple levels; but I can't
figure out a way to properly move between them while keeping my button
code the same. I don't want to have to make an "obj_button_yes_level1"
that spawns when the user picks Level 1, for example. I just want to make
"obj_button_yes" so I'm not eating up valuable resource space.
I've tried this a few ways, neither of which has worked.
Firstly I made something that looked like this:
global.current_question_level =
string("global.level"+string(gl
obal.level_number)+"_questions"
)
This one would spawn the initial question, as I wanted; but as soon as I
gave a single answer it would end - saying it had finished all of the
questions. I don't quite get why, tbh.
The second way I tried was this:
//Init
global.array_level_questions[25
] = 0
//Usage
global.current_level_questions
=
global.array_level_questions[gl
obal.level_number]
//Creating the questions for
Level 1
global.array_level_questions[1]
= global.level1_questions;
global.level1_questions =
ds_list_create();
ds_list_add(global.level1_quest
ions, obj_level1_1);
But this just straight-up doesn't work. It makes me think that, perhaps, GML
doesn't use arrays in the way I'm used to with other C-based languages?
Any guidance would be extremely appreciated =)
Sorry for the long post!!!
Edit:
Still broken.
So as talked about in the comments, I added a For loop to initialize the
variables; but that didn't help. I'll copy my starting script, as well as the
error it displays:
//Initialize variables
global.level_number = 1;
global.correct_answers = 0;
global.question_number = 1;
global.clickable = 1;
//Init
for (i = 0; i < 25; i++){
global.array_level_questions[i]
= 0;
}
global.level1_questions =
ds_list_create();
ds_list_add(global.level1_quest
ions, obj_level1_1);
//Et cetera
ds_list_add(global.level1_quest
ions, obj_level1_12);
//Randomizes questions
ds_list_shuffle(global.level1_q
uestions);
//Usage
global.current_level_questions
= 0;
global.current_level_questions
=
global.array_level_questions[gl
obal.level_number];
instance_create(0, 0,
obj_current_question);
instance_create(0, 0,
obj_correct_answers);
That line previously worked when I was not using the arrays, so I'm not sure
why it is not anymore D=
Again, any help would be massively appreciated
13 comments
share
report
all 13 comments
sorted by:
best
[]SaladLizard 1 point 2 years ago
Initialising that array like this:
global.array_level_questions[25]=0;
is only going to set the 25th value to 0, so the rest of the values are
undefined. Use a loop to define them all.
permalink
embed
[]bassman2112 S 0 points 2 years ago
[ ]
I assumed it would create and initialize everything up until that point haha -
guess GML doesn't work exactly like other C-based languages.
I'm on my phone, but would you do a for loop? Something like this?
For (i = 0; i > 25: i++) {
global.array_level_questions[i] = 0
}
Otherwise, does it seem like my syntax is reasonable?
Thanks a ton
permalink
embed
parent
[]TheWinslow 2 points 2 years ago
That for loop will never run but that is the basic idea.
permalink
embed
parent
[]bassman2112 S 1 point 2 years ago*
[ ]
Thanks =D
Sorry to bug, but would you be willing to take a look at my edit and see if
you have any advice? =)
permalink
embed
parent
[]TheWinslow 1 point 2 years ago
//Creating the
questions for
Level 1
global.level1_qu
estions = 0;
global.array_lev
el_questions[1]
=
global.level1_qu
estions;
global.level1_qu
estions =
ds_list_create()
;
ds_list_add(glob
al.level1_questi
ons,
obj_level1_1);
//Et cetera
ds_list_add(glob
al.level1_questi
ons,
obj_level1_12);
//Randomizes
questions
ds_list_shuffle(
global.level1_qu
estions);
//Init
for (i = 0; i
< 10; i++){
global.array_
level_questio
ns[i] = 0;
}
//Usage
global.curren
t_level_quest
ions = 0;
//-----------
-------------
-------------
-------------
-------------
----------//
//
LEVEL 1
QUESTIONS
//
//-----------
-------------
-------------
-------------
-------------
----------//
//Init
global.level1
_questions =
0;
//Creating
questions for
Level 1
global.level1
_questions =
ds_list_creat
e();
ds_list_add(g
lobal.level1_
questions,
obj_level1_1)
;
//Etc
ds_list_add(g
lobal.level1_
questions,
obj_level1_12
);
//Randomizes
questions
ds_list_shuff
le(global.lev
el1_questions
);
//Inserts
Level 1
questions
into proper
Array spot
global.array_
level_questio
ns[1] =
global.level1
_questions;
global.curren
t_level_quest
ions =
global.array_
level_questio
ns[global.lev
el_number];
permalink
embed
parent
[]mixmax2 1 point 2 years ago
i < 25
permalink
embed
parent
[]bassman2112 S 1 point 2 years ago
[ ]
//Usage
global.current_level_questions
=
global.array_level_questions[gl
obal.level_number]