Mr.Celsuis
Member
So, I dont really have a problem, just a question. I'm kinda new to game maker, I just started like 4 months ago, but I feel like I have a bad coding style, or that I act way to much like a huge noob sometimes, I do realize I am new but is being considered good at gamemaker writing all this code in one script like, and I literally just took this out of one of yoyogames blogs
// @function Textfield(string:name, real:x, real:y, string:value)
function Textfield(_name, _x, _y, _value) : GUIElement() constructor {
// passed-in vars
name = _name;
x = _x;
y = _y;
/// @function set(string:str)
static set = function(str) {
// value hasn't changed; quit
if (value == str) return;
value = str;
show_debug_message("You set the Textfield named `" + string(name) + "` to the value `" + string(value) + "`");
}
/// @function click()
static click = function() {
set_focus();
keyboard_string = get();
}
/// @function listen()
static listen = function() {
set(keyboard_string);
if (keyboard_check_pressed(vk_enter)) remove_focus();
}
/// @function draw()
static draw = function() {
draw_set_alpha(has_focus() ? 1 : 0.5);
// bounding box
draw_rectangle(x, y, x + width, y + height, true);
// draw input text
draw_text(x + padding, y + (height * 0.5), get());
draw_set_alpha(1);
}
// set value
set(_value);
}
and now what all of this means?! is that the level I should be able to code at by now? I do realize that everybody learns at a slow pace, but I tried studying the manual and everything but I still only write with and if statements for the most part, and thats it. I know this is kinda an odd question, but if anyone could reassure me I would greatly appreciate it.
// @function Textfield(string:name, real:x, real:y, string:value)
function Textfield(_name, _x, _y, _value) : GUIElement() constructor {
// passed-in vars
name = _name;
x = _x;
y = _y;
/// @function set(string:str)
static set = function(str) {
// value hasn't changed; quit
if (value == str) return;
value = str;
show_debug_message("You set the Textfield named `" + string(name) + "` to the value `" + string(value) + "`");
}
/// @function click()
static click = function() {
set_focus();
keyboard_string = get();
}
/// @function listen()
static listen = function() {
set(keyboard_string);
if (keyboard_check_pressed(vk_enter)) remove_focus();
}
/// @function draw()
static draw = function() {
draw_set_alpha(has_focus() ? 1 : 0.5);
// bounding box
draw_rectangle(x, y, x + width, y + height, true);
// draw input text
draw_text(x + padding, y + (height * 0.5), get());
draw_set_alpha(1);
}
// set value
set(_value);
}
and now what all of this means?! is that the level I should be able to code at by now? I do realize that everybody learns at a slow pace, but I tried studying the manual and everything but I still only write with and if statements for the most part, and thats it. I know this is kinda an odd question, but if anyone could reassure me I would greatly appreciate it.