V
vidboy
Guest
I'm on the edge of my seat (#169458).
Same, about 250 from mine as well. I am sure in around 2 weeks we will get in but I imagine the beta ain't gonna last for too much longer.Still got about ~250 to go But it'll get there. Surely. Certainly. Hopefully. *uncontrollable sobbing*
*Squees in 169449*Got an email an hour and a bit ago letting me know I'm in =D (#169416)
Interesting...so the bottom init(_sprite_index); would cause it to run itself when an "enemy = new Enemy(spr_enemy);" is called? But it would have to be below the function's definition inside the struct? This'll be super handy for spawning things in code!BPOutlaws_JeffGML:function Enemy(_sprite_index) constructor { _duration = 0; _state = 0; init = function(_sprite_index) { sprite_index = _sprite_index; idle(60); } idle = function(_duration) { _duration = _duration; _state = 0; } step = function(){//call enemy.step() in step event switch( _state ){ case 0: if (!_duration--) { show_debug_message("duration over") } break; } } init(_sprite_index);// you can call it inner function just in one event step. }
Something like this.
I hear people in Unity do something like this so maybe some Unity tutorials would give you ideas on best practices. I'm used to the GMS setup but I'm definitely leaning toward trying something like this out although when you get to functions or audio etc that can be shared that might get a little messy...Now that the Assets Browser has been re-designed to allow us to structure it anyway that we want, I'm trying to figure out how I want to go about this. I thought about doing something like
That's something I've been kicking around. Anyone else thought of how they may redo their stuff?Code:Player Sprites Functions Objects Enemies Sprites Functions Objects
lol I hear ya. I'm redoing parts of my game or common tasks with rough ideas of how to approach it using this new stuff to figure out where I can clean things up and do them more efficiently but it's all running blind on what any best practices are for this. Plus I was looking up tutorials in general and there's a ton of "OOP is bad, use procedural/functional programming" stuff on YouTube which is like, wait are we getting features that we shouldn't be using? lol I'm sure those vids are just talking about people abusing OOP and classes to the point where it's counter-productive which gives the feeling that we're being handed a double-edged sword and approach it carefully.I'm struggling with all this. Every time someone posts some code the layout is different. I'm still trying though.
I am struggling to figure out how to glue everything together.
//--------------------------------------------------
//obj_game
//--------------------------------------------------
//Create Event
settings = {
enum diff {easy, medium, hard}//can I put these in here so the relevant ones are in one place?
enum gfx {high, medium, low}
difficulty: diff.easy;
gfx_detail: gfx.high;
music_volume: 10;
sfx_volume: 10;
keyboard: {//I have no idea what kind of best practice doing controller supports would be lol
right: vk_right;
attack: vk_space;
//etc...
}
gamepad: {
right: gp_padr;
attack: gp_face1;
//etc...
}
}
input = {//only gonna create one of these inside the obj_game object...no more need for an obj_input handler?
enum key {up, down, left, right, attack, check, pressed, released}
#macro INPUT obj_game.input//can I throw macros in here so the related ones are all in one place? lol
#macro RIGHT_CHECK INPUT.get_input(INPUT.binds.right, INPUT.binds.check )
#macro RIGHT_PRESSED INPUT.get_input(INPUT.binds.right, INPUT.binds.pressed )
#macro RIGHT_RELEASED INPUT.get_input(INPUT.binds.right, INPUT.binds.released)
#macro ATTACK_CHECK INPUT.get_input(INPUT.binds.attack, INPUT.binds.check )
#macro ATTACK_PRESSED INPUT.get_input(INPUT.binds.attack, INPUT.binds.pressed )
#macro ATTACK_RELEASED INPUT.get_input(INPUT.binds.attack, INPUT.binds.released)
//etc..
binds = {
right: [settings.keyboard.right, settings.gamepad.right ]
attack: [settings.keyboard.attack, settings.gamepad.attack]
//etc..
}
get_input = function(_bind, _type) {
switch (_type) { //excuse my OCD lol
case key.check: return keyboard_check( _bind[0]) + gamepad_check_button( 0, _bind[1]); break;
case key.pressed: return keyboard_check_pressed( _bind[0]) + gamepad_check_button_pressed( 0, _bind[1]); break;
case key.released: return keyboard_check_released(_bind[0]) + gamepad_check_button_released(0, _bind[1]); break;
}
}
}
//--------------------------------------------------
//scr_components
//--------------------------------------------------
Anim = function() constructor {
play = function(_anim_name) {skeleton_animation_set(_anim_name);}
is_done = function() {return image_index + image_speed == image_number - 1;}
current = function(_anim_name) {return skeleton_animation_get() == _anim_name;}
}
//--------------------------------------------------
//obj_player
//--------------------------------------------------
//Create Event
anim = new Anim();
anim.play("idle");
//Step Event
if (RIGHT_CHECK && ATTACK_PRESSED) {anim.play("shoryuken");}
if (anim.current("shoryuken") && anim.is_done()) {anim.play("idle");}
//inside obj_game:
input.pressed(dir.right);
audio.play(bgm_song);
replay.start_recording("recording.txt");
menus.create("Main Menu");
enemies.update_all();
This was super useful, thanks! The diagrams really cleared things up!It's not that difficult...
1) When younew MyFunctionMarkedAsConstructor()
you are creating an "instance" and returning it.
2) This "instance" is different from the instances made from objects.. it's calledstruct
(AKA lightweight object instance)
3) As you might imagine inside thatstruct
you can have variables and those are independent from the instance ones.
############### LETS LOOK AT THE IMAGE BELOW #############
View attachment 30996
### LETS LOOK AT ANOTHER EXAMPLE WITH CONSTRUCTOR PARAMS ###GML://0) you create an instance of objBase //1) in the create event you set the x and y (of the instance to 10 and 22) //2) you create a struct of type MyStruct //3) this is an individual entity that as nothing to do with the instance //4) you set variables inside the struct 'a' //5) the x and y inside the struct are not the same from the instance.
View attachment 30998
[CONCLUSION] the x and y inside the struct is not the x and y inside the instanceGML://0) you create an instance of objBase //1) in the create event you set the x and y (of the instance to 10 and 22) //2) you create a struct of type MyStruct and pass (100 and 200 as params) //3) the struct is created and the 'struct variables' are set
[EXTRA]
If you want to change the instance position you need to either:
1) remove the constructor keyword from the function.
OR
2) use other keyword before the x/y variables.
Either way:
- If the function is marked as a constructor you should NOT call it as a function.
- If it is NOT a constructor you shoudn't be calling it with new.
This is great! As someone who uses a ton of Spine stuff in my games I'm really curious to see what the sequencer can do and how it plays with Spine and what kind of tasks seem better to do in the sequencer than in Spine and how to combine the two and see what they can do together.Not fancy, but just spent a short time learning the ropes and building this. Time invested in total was about an hour learning and implementing, so pretty short all things considered.
The old way was undocumented behaviour, and subject to change at any time, so you should never be using it in your projects. The new way is also undocumented behaviour and will remain so as it could change at any time.Since the IDE now allows us to rearrange everything, how does that work with the resource ids? GMS2.2 assigns object ids to the objects based on the order they appear in the tree from top to bottom (I assume the same goes for other resources as well). What is 2.3 doing? Are the assets, as they're now called, assigned numbers according to their current position or is there a fixed arrangement “behind the scenes” while the rearranging we do is merely superficial? I actually use this quirk of GMS2.2 so I'm curious how I may or may not have to change things.
No. A struct is essentially a new data-type and has nothing to do with instances and objects... which is why the name "lightweight object" was dropped, as they aren't really.Second set of questions: structs are all instances correct? If I create a struct with whatever way of doing so, the thing I've created is a lightweight instance, even though people here have been calling them lightweight objects. Is this correct? From what I've seen of the dot notation used to access the variables inside a struct, and the lack of functions to get the equivalent of instance ids for structs, this is the only thing that makes sense.
No, this is not correct. While the struct is a separate entity, it's still bound to the instance that created it by the variable the struct reference was assigned to.Also, if I create a struct inside obj_whatever, I don't access the struct by using obj_whatever.struct.x; rather, I just use struct.x no matter what the scope is, right? Do I therefore get an error if I try to make two structs with the same name from within different objects?
What does sequences phase 2 add?Oh, new 2.3 update available (23.1.1.141)!
Though... On the weekend and it's not signed?
You can basically use scripts as before, they just need add bit extra line which is easy to learn. Also GMS automatically creates these lines for you when you import 2.2 project to 2.3. Scripts can have many functions though, which is useful for organizing.I understand adding new programming to the game and handling scripts differently, but can't the current script system also coexist with the newer system so we don't have to relearn how to do all the scripts in our game?
Also how do I apply to test it out? Super super excited for the sequences (as a video editor I'm sure I'll have lots of feedback for that), and I also want to get the jump on things we will need to update in our game to make everything function on the new version. Thanks!
It's the weekend. There are no new ticket id's. If you would have taken the time to look at the thread you would have seen that the highest ticket number, so far reported, was mine at 169427.What's the newest ticket id?
I should be waiting for the end of the month.It's the weekend. There are no new ticket id's. If you would have taken the time to look at the thread you would have seen that the highest ticket number, so far reported, was mine at 169427.
Edit: Unless someone I've "ignored" posted on here with a higher number lol. But I've only "ignored" 6 people so that's unlikely.
What ticket number are you?I should be waiting for the end of the month.
196512What ticket number are you?
It's just speculation but you'll probably get the beta around the end of this week196512
As your lucky words would say !It's just speculation but you'll probably get the beta around the end of this week
/////////////////////////
//////Public Script
function test_parent() constructor{
static say = function(){ show_debug_message("say something...."); }
}
function test_child():test_parent() constructor{
old_say = say;// If the old_say isn't static the project will be crashed when create two or more instance
static say= function(){
old_say();
show_debug_message("say anything....");
}
}
//BUG happened when creating two or more instances
///////////////////////
//////Object Create Event
temp = new test_child();
///////////////////////
//////Object Step Event
temp.say();
I'm able to reproduce this in runtimes 23.1.1.123 and 23.1.1.118, and this definitely looks like a contradiction against YoYo's previous advice. I will ask for an explanation in the closed beta forum. It could be a permanent change behind the scenes or an untested bug.Is this an existed bug for static when overwriting the parent static method variable.
Or just syntax error?
@FrostyCat
@xDGameStudios
GML:///////////////////////// //////Public Script function test_parent() constructor{ static say = function(){ show_debug_message("say something...."); } } function test_child():test_parent() constructor{ old_say = say;// If the old_say isn't static the project will be crashed when create two or more instance static say= function(){ old_say(); show_debug_message("say anything...."); } } //BUG happened when creating two or more instances /////////////////////// //////Object Create Event temp = new test_child(); /////////////////////// //////Object Step Event temp.say();
Thank you very much!I'm able to reproduce this in runtimes 23.1.1.123 and 23.1.1.118, and this definitely looks like a contradiction against YoYo's previous advice. I will ask for an explanation in the closed beta forum. It could be a permanent change behind the scenes or an untested bug.
//--------------------------------------------------
//scr_points
//--------------------------------------------------
function Points() constructor {
list_points = ds_list_create();
add = function(x_off, _y_off) {
var _index = ds_list_size(list_points);
list_points[| _index] = new Point(_index, _x_off, _y_off);
}
delete = function(_index) {
ds_list_delete(list_points[| _index]);
}
cleanup = function() {
ds_destroy(list_points, ds_type_list);
}
update_points = function(_id) {
if (EDIT_MODE) {
var _i = 0;
repeat (ds_list_size(list_points)) {
list_points[| _i++].update(_id);
}
}
}
draw_points = function(_id) {
if (EDIT_MODE) {
var _i = 0;
repeat (ds_list_size(list_points)) {
list_points[| _i++].draw(_id);
}
}
}
}
function Point(_index_, x_off, _y_off) constructor {
edit = new Edit();
index = _index;
x_off = _x_off;
y_off = _y_off;
update = function(_id) {
edit.check_mouse_drag(_id);
edit.check_delete(_id);
}
draw = function(_id) {
draw_circle(_id.x + x_off, _id.y + y_off, 10, true);
}
}
function Edit() constructor {
mouse_over = function(_id) {
return point_distance(mouse_x, mouse_y, _id.x + x_off, _id.y + y_off) <= 5;
}
mouse_drag = function(_id) {
if (mouse_over(_id)) && mouse_check_button(mb_left)) {
if (mouse_check_button_pressed(mb_left)) {
x_origin = x_off;
y_origin = y_off;
}
x_off = x_origin + (mouse_x - x_off);
y_off = y_origin + (mouse_y - y_off);
}
}
check_delete = function(_id) {
if (mouse_over(_id) && keyboard_check_pressed(vk_delete)) {
_id.points.delete(index);
}
}
}
//--------------------------------------------------
//obj_enemy
//--------------------------------------------------
//Create Event
points = new Points();
points.add( 0, 0);
points.add(100, 0);
points.add(100, 100);
points.add( 0, 100);
//Step Event
points.update_points(_id);
//Draw Event
points.draw_points(_id);
//Cleanup Event
points.cleanup();
function Points() constructor {
list_points = ds_list_create();
add = function(x_off, _y_off) {
var _index = ds_list_size(list_points);
list_points[| _index] = {
edit = new Edit();
index = _index;
x_off = _x_off;
y_off = _y_off;
update = function(_id) {
edit.check_mouse_drag(_id);
edit.check_delete(_id);
}
draw = function(_id) {
draw_circle(_id.x + x_off, _id.y + y_off, 10, true);
}
}
}
}
function point(_necessary_var, _optional_var) constructor {
var1 = _necessary_var;
var2 = (argument_count > 1 ? _optional_var : 100);//default value
//is this ^^^^^^^^^^^^^ allowed or does it HAVE to use ugly ol' argument[1] :( lol
//and if so then can this be a feature request to be able to do this? :) PLEASE!! :D
}
function point(_necessary_var, [_optional_var]) constructor {
This is absolutely possible and should work as you've written it IIRC.2) @FrostyCat answered this earlier but just to clarify a detail of it, can I do this:
GML:function point(_necessary_var, _optional_var) constructor { var1 = _necessary_var; var2 = (argument_count > 1 ? _optional_var : 100);//default value //is this ^^^^^^^^^^^^^ allowed or does it HAVE to use ugly ol' argument[1] :( lol //and if so then can this be a feature request to be able to do this? :) PLEASE!! :D }
Every argument is technically optional. You will get no syntax error if you don't use an argument, nor will the compiler or runtime throw an error for not using an argument.3) Is there a way to indicate a variable is optional? Like:
GML:function point(_necessary_var, [_optional_var]) constructor {
2) @FrostyCat answered this earlier but just to clarify a detail of it, can I do this:
function point(_necessary_var, _optional_var) constructor {
var1 = _necessary_var;
var2 = _optional_var == undefined ? 100 : _optional_var
}
IIRC, the room editor now has rulers, and things should be able to snap to them. Other than that though, no updates... However I believe the room editor will be getting a re-vamp sometime in the near-ish future.A question about 2.3 that is not about functions and structs for a change: has there been any significant feature additions to the room editor? I've noticed a few things I've missed to speed up work have been the ability to offset the grid, and having assets snap to grid by their sprite and bounding box edges, optimally as toggleable features.
Yes, that doesn't sound like a solution I'm looking for. The use case I'm talking about: I might have sprites sized 32x32 - and their multiples - and I can quickly align them to a grid of same size, either as objects to object layers or as sprites to sprite layers. However not all sprites have their origin at bottom left because of 2.5D depth ordering system. When they snap by origin they are misaligned with the rest. Snapping by sprite edge would solve this.IIRC, the room editor now has rulers, and things should be able to snap to them. Other than that though, no updates... However I believe the room editor will be getting a re-vamp sometime in the near-ish future.
Do you get the access today?I'm on the edge of my seat (#169458).
Got invited some minutes ago #169503what's the latest id now?
Yes!!!! I got that too!!!!!!Got invited some minutes ago #169503
Have fun playing around with it and to learn new stuffYes!!!! I got that too!!!!!!
Woooooooooo Eeeeeeeeeee
About 50~100 per week.Here 169776 and still nothing (( how many days again??
Awesome! List sort with callback is what I missed so much in GMS. Did you compare performance against built-in functions?The lightweight data structures library that I have been working on since the beginning of the month is finally complete: https://github.com/dicksonlaw583/LightweightDataStructures
There are a couple of regressions from the last runtime to the current one that prevents the library from showing its full potential. But at the very least it's ready for an open beta showing what the new OOP features can offer.
Not yet, I want to be more certain about its correctness before looking into its performance. Due to several regressions in runtime 23.1.1.123, I have been unable to run the test suite on YYC and HTML5 where I would like to know the most about performance impacts. I have a gut feeling it will be slower because it is on GML speed instead of native speed, but hopefully the possibilities it opens will be worth the expense.Awesome! List sort with callback is what I missed so much in GMS. Did you compare performance against built-in functions?
what about, doing this?Just wondering, is this valid syntax with the new array system? That would be amazing.
array = [1, 2, 3][4, 5, 6];
array = [[1, 2, 3], [4, 5, 6]];
// array[0] == [1, 2, 3];
// array[0][0] == 1
// array[0][1] == 2
// array[0][2] == 3
Close, but not exactly like that. xDGameStudios has the correct syntax in post #947.Just wondering, is this valid syntax with the new array system? That would be amazing.
array = [1, 2, 3][4, 5, 6];
GML:array = [[1, 2, 3], [4, 5, 6]]; // array[0] == [1, 2, 3]; // array[0][0] == 1 // array[0][1] == 2 // array[0][2] == 3
Oh, that works too! thanks.what about, doing this?
GML:array = [[1, 2, 3], [4, 5, 6]]; // array[0] == [1, 2, 3]; // array[0][0] == 1 // array[0][1] == 2 // array[0][2] == 3
is there something wrong with this?
I think you can also go as deep as you can, haven't tested it yet, but bit like this:Oh, that works too! thanks.