|
Paul Eres
|
 |
« Reply #165 on: November 11, 2008, 04:27:58 AM » |
|
It lets you execute code *as if* you're in a class of objects (or parent class) from inside other objects. That sounds simple, but it leads to a lot of nice uses. As a simple use for it, imagine you want to draw reflections of every object in the game on the water, the way I do in Saturated Dreamers here:  But you don't want each object to draw its own reflection, because you want them all on the water, on the same layer. So what you could do is, in the water object's draw event, do with(obj_map) { (code to draw the reflection) } 'obj_map' there would be a parent object of all objects that you want to reflect. Now that might not seem like much, because you can accomplish the same thing in other ways in C++, such as having an array of every object, but it's the simplest way to accomplish it in GML. There are more sophisticated uses of it of course, but I wanted to show an easy example. You can use the word "other" within the code to refer back to the object that created the with() construction, so for instance if you want to draw a line between an object and every other object, you could do with(obj_map) draw_line(x, y, other.x, other.y); You can also nestle them, which is occasionally useful. I can't think of any clear examples to explain that right now, but that's because I'm tired; but I've used nestled with()'s many times. You can even backtrack and do with(other) to create a section of code within that section of code which refers to the original object. You can also use with() for individual instances rather than types of object, if you use the instance id rather than the object id. An interesting thing is that using with() statements is kind of analogous to calling functions for classes in C++, because the code is called from that particular GM object. Though I think with() is even more flexible.
|
|
|
|
« Last Edit: November 11, 2008, 04:38:15 AM by rinkuhero »
|
Logged
|
|
|
|
|
increpare
Guest
|
 |
« Reply #166 on: November 11, 2008, 05:16:02 AM » |
|
ah okay, so it acts like a for-loop running through one's array of entities, and to use their member-variables without having to prefix them with "entityarray[ i ].". (though in C++ you'd probably be better off making 'draw_reflection' a member function of entity). Anyway. yep, I can see the niceness of that.
cheers.
|
|
|
|
« Last Edit: November 11, 2008, 05:19:11 AM by increpare »
|
Logged
|
|
|
|
|
Corpus
Guest
|
 |
« Reply #167 on: November 11, 2008, 08:34:59 AM » |
|
As I discovered to my horror and mild frustration at the jam, GML has no means of defining initialiser lists for arrays.
WHAT IS UP WITH THAT
|
|
|
|
|
Logged
|
|
|
|
|
Paul Eres
|
 |
« Reply #168 on: November 11, 2008, 09:46:29 AM » |
|
You can probably code your own method for initiailizing arrays, something like:
init_1Darray(arrayname, value1, value2, value3, value4, ...);
But GM's arrays are horrible in general: you can only have double arrays, and you can't use array indexes more than 32000 (and if you use a double array, the two array indexes combined can't exceed 32000). Its arrays are also very slow. Yes, using arrays can slow down your game, especially if you use them in long loops. Its data structures are much better in pretty much every way, so you can just use a data structure for an array.
People familiar with GM quickly learn a few things about it: never use execute_string(), never stretch the game to full screen, never use the GM's built-in sound functions for anything (use a dll), and never use arrays.
|
|
|
|
|
Logged
|
|
|
|
|
Pishtaco
|
 |
« Reply #169 on: November 11, 2008, 11:12:07 PM » |
|
People familiar with GM quickly learn a few things about it: never use execute_string(), never stretch the game to full screen, never use the GM's built-in sound functions for anything (use a dll), and never use arrays.
Thanks for the helpful posts. What do you mean about full screen - I found that pressing f4 in game to switch to full-screen seems to work fine - and what's wrong with the sound functions and a good dll to use instead? And, if you do use arrays, is there a way to initialize their size? I couldn't work this out from the manual.
|
|
|
|
|
Logged
|
|
|
|
Mir@k
Level 1
Nothing becomes something
|
 |
« Reply #170 on: November 11, 2008, 11:23:13 PM » |
|
I'd like to hear reccomendations for said .dll's. :|
|
|
|
|
|
Logged
|
|
|
|
|
Skofo
|
 |
« Reply #171 on: November 12, 2008, 06:07:39 AM » |
|
People familiar with GM quickly learn a few things about it: never use execute_string(), never stretch the game to full screen, never use the GM's built-in sound functions for anything (use a dll), and never use arrays.
Thanks for the helpful posts. What do you mean about full screen - I found that pressing f4 in game to switch to full-screen seems to work fine - and what's wrong with the sound functions and a good dll to use instead? And, if you do use arrays, is there a way to initialize their size? I couldn't work this out from the manual. Resizing to full screen in Game Maker is usually pretty ugly. Game Maker decides to assblur everything. Also, I don't know what rinku means about the sound, I've never had any problems. I guess he means this? If there's anything in Game Maker that you shouldn't use, it's its built-in multiplayer functionality. Absolutely horrible.
|
|
|
|
|
Logged
|
If you wish to make a video game from scratch, you must first invent the universe.
|
|
|
|
Paul Eres
|
 |
« Reply #172 on: November 12, 2008, 11:20:51 AM » |
|
Skofo is right about the full screen stretching mode. Either switch the resolution to a dedicated resolution or use windowed mode, never stretch to full screen mode. Not only does it make it terribly blurry, but it also reduces the fps and slows the game drastically. They really should not include that option in GM, and if I were Overmars I'd remove it immediately, since as a result of it most GM games look horribly blurry and it gives a bad impression of GM for people who play those games. Even some of the "100 GM games in 10 minutes" games used that stretching thing, although thankfully most didn't.
As for the sound engine, use fmod, bass, or supersound dll's. Any works fine. GM's own sound ability is severely lacking:
- there are huge delays between when you tell a sound to play and when it plays, due to it uses windows media player as its output - when playing midi's, there's often a horrible scratchy sound that you get - when playing mp3's, it re-loads the mp3 each time it loops, causing a delay in the looping rather than a smooth loop - it can't play mod's, ogg's, or any other format other than wav, midi, and mp3, which are (except for wav) not formats you should ever use in a polished game
|
|
|
|
|
Logged
|
|
|
|
|
Pishtaco
|
 |
« Reply #173 on: November 13, 2008, 11:39:17 PM » |
|
Skofo is right about the full screen stretching mode. Either switch the resolution to a dedicated resolution or use windowed mode, never stretch to full screen mode. Not only does it make it terribly blurry, but it also reduces the fps and slows the game drastically. They really should not include that option in GM, and if I were Overmars I'd remove it immediately, since as a result of it most GM games look horribly blurry and it gives a bad impression of GM for people who play those games. Even some of the "100 GM games in 10 minutes" games used that stretching thing, although thankfully most didn't.
As for the sound engine, use fmod, bass, or supersound dll's. Any works fine. GM's own sound ability is severely lacking:
- there are huge delays between when you tell a sound to play and when it plays, due to it uses windows media player as its output - when playing midi's, there's often a horrible scratchy sound that you get - when playing mp3's, it re-loads the mp3 each time it loops, causing a delay in the looping rather than a smooth loop - it can't play mod's, ogg's, or any other format other than wav, midi, and mp3, which are (except for wav) not formats you should ever use in a polished game
Thanks! I've been playing games that are deliberately a bit blurry, so that hasn't registered as a problem yet. I'm interested in the sound problems, because the game I'm hoping to find time for for the competition needs carefully timed sounds. But these will be small .wavs, so does this delay problem still turn up there? I thought that gamemaker only used the media player for things like mp3s.
|
|
|
|
|
Logged
|
|
|
|
|
Paul Eres
|
 |
« Reply #174 on: November 13, 2008, 11:42:40 PM » |
|
Personally I don't trust it enough to even use it for wav's, but do your own experiments and be your own judge, I'd say. Using a dll is fairly simple, so I don't see any real reason not to use one, unless you just never used a dll before or something.
|
|
|
|
|
Logged
|
|
|
|
|
GregWS
|
 |
« Reply #175 on: November 14, 2008, 09:06:08 PM » |
|
So rinku, would you mind throwing together a crash course "dlls in GM" tutorial in the Tutorials forum? That would rock!  (The alternative being lots of time spent in the help file, and I'm getting really sick of that as a primary method of learning the higher functions of GM.)
|
|
|
|
|
Logged
|
|
|
|
|
Paul Eres
|
 |
« Reply #176 on: November 14, 2008, 09:15:54 PM » |
|
It's not really lengthy enough to even require a tutorial; I can explain it all in one paragraph. Here's an example, using supersound.dll. Download. Extract all files in a folder. If you're using GM7, open the .gmd file in Game Maker (you may need to select "load older Game Maker files" in the file menu, since that one's saved in an older version of GM). Run it and test it out to make sure it works. Look at the scripts if you like. Save the game, just to have it in the newer format for newer versions of GM. Load your own game. Choose "merge game" and merge the two games together. You can now use the functions from SuperSound dll, as long as that .dll is in your game's directory. Each function's name is self-explanatory (and usually has comments explaining how to use it) and works just like a normal GML function, it's basically like adding a new set of GML functions to your game.
|
|
|
|
|
Logged
|
|
|
|
|
GregWS
|
 |
« Reply #177 on: November 14, 2008, 09:23:13 PM » |
|
Thanks rinku! I'm going to need to use one for sound in my sketched shmup, probably to play mods. I'm thinking of recording some samples of me sketching lines (eg. a straight line, a curvy line, a circle) and then using these samples to make some music (or begging someone on TIGS to make music for me; wouldn't do that until I have a playable game I'm happy with to though).
|
|
|
|
|
Logged
|
|
|
|
|
Tanner
|
 |
« Reply #178 on: November 15, 2008, 11:14:07 PM » |
|
there's a pxtone dll somewhere. you should use that. pxtone needs some lovin'.
|
|
|
|
|
Logged
|
First play the game, then let the game play you, then you play game. - Hamletz
|
|
|
|
GregWS
|
 |
« Reply #179 on: November 16, 2008, 09:51:44 PM » |
|
I'd thought of that actually; I've messed around with PXTone a little bit, and it seemed pretty good. That's what YMM now uses unless I'm mistaken.
|
|
|
|
|
Logged
|
|
|
|
|