Тёмный

Macros, Singletons, and Static Classes - GameMaker Tutorial 

DragoniteSpam
Подписаться 10 тыс.
Просмотров 1,5 тыс.
50% 1

Опубликовано:

 

31 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 7   
@mayathemaster
@mayathemaster 4 года назад
This is a wonderful design pattern, definetly bringing my input system to this idea
@DragoniteSpam
@DragoniteSpam 4 года назад
I really like it for certain things, but I did some profiling recently and there _is_ more overhead in calling a function than I'd really like (at least on the VM - the YYC and inline code should make it quite a bit nicer). It's more performant in some situations than other - but it can be nicer to write code for!
@indiepunch3443
@indiepunch3443 4 года назад
Thank you for another awesome video, 17:35 no problem I hope I can continue to contribute to your channel for a long time!
@sabriath
@sabriath 4 года назад
Just a note....calling a function in order to return a struct that you point-reference into in order to get a variable or run a function will eventually slow down your game. A better option would simply be to just create it as a global variable and use a macro to point to the global.....since anything in a script file that is outside of a function will be initialized once anyway. So something like: global.__time = { blah blah blah} #macro Time global.__time This way there is no calling any functionality or returning a struct, the macro replaces it in preprocessing so it's as if you wrote the entire thing out directly. This does make the autoupdate feature you added at the end of the video not available....but you could add it to the macro, if you REALLY want it to update, like this (just have 'Update' return 0): #macro Time global.__time.update()+global.__time So if you were to write: var a = Time.dt; It gets replaced with: var a = global.__time.update()+global.__time.dt; GMS runs the update function before it resolves the point reference to 'dt', so 'dt' will be updated by the time it gets the value. This way you only call 1 function, rather than 2.
@DragoniteSpam
@DragoniteSpam 4 года назад
If you call it constantly, yeah, although overhead from a function call itself isn't THAT much. If I need to use Time more than once or twice in a section of code I'll usually save it to a local variable at the top of the script. Random globals floating around usually get on my nerves after a while.
@sabriath
@sabriath 4 года назад
@@DragoniteSpam ...I was mainly just giving an alternative to using a function, that's all. I'm old school, so globals are part of my blood, having to instantiate objects just to hold variables for all other objects to look at "gets on MY nerves after a while"....lol. I think you call them singletons? Yeah, I don't like those.
@barberousse1149
@barberousse1149 10 месяцев назад
cool trick! I was trying to do this recently... static class, like this.that. Thanks. Technically dt or whatev could also be functions ensuring its updated (or something specific to that memeber) before returning. then could you just put up some macro within get_static_time so you dont need () ?! code reviewers might scream because condescending nature but.... anything to not go global, hurts my eyes and private requirements...
Далее
How To Use Macros (And How To Not) - GameMaker Tutorial
31:38
Static Variables [GameMaker Studio 2.3]
12:16
Просмотров 1,7 тыс.
На кого пойти учиться?
00:55
Просмотров 247 тыс.
Lorikeet - Fast Palette Swapping in GameMaker
23:55
Просмотров 2,8 тыс.
Weighted Randomness in GameMaker
19:53
Просмотров 624
I Made the Same Game in 8 Engines
12:34
Просмотров 4,2 млн
Move And Collide with Slopes - Gamemaker Tutorial
14:49
I Tried Pixel Sorting, but in a Falling Sand Game
12:19