Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411613 Posts in 69390 Topics- by 58447 Members - Latest Member: sinsofsven

May 09, 2024, 08:10:48 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)2D Array Performance in Game Maker
Pages: [1]
Print
Author Topic: 2D Array Performance in Game Maker  (Read 7307 times)
Super-Dot
Level 1
*


hup hup


View Profile
« on: May 01, 2009, 12:18:13 PM »

So I'm working on a game which involves computing the next generation of the Game of Life. This is really slow in Game Maker. I'm using two ds_grids and two for loops. It takes about half a second. In the prototype, each generation lasts a second; to get it working, I ended up spreading the computation over each step rather than computing the whole thing in one step to prevent the game from freezing every generation.

This is suboptimal!

What I'm wondering is if there's a way to speed up the computation, ideally to the extent that I can compute the whole thing in one step. Then I could do cool things and fancy things and my code would be squeaky-clean.

The grid size right now is 80x60, so I'm not sure that fancy stuff like HashLife would yield many improvements. I'm mostly wondering if I can use DLLs or Extensions to make things better, or if there are ways to work with arrays (ds_grids or otherwise) fastly.
Logged

Kelsey Higham, student at SJSU
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #1 on: May 01, 2009, 12:36:52 PM »

Dude, you are a CS student and writing Life in GameMaker?
Use some other language (say something that actually supports arrays at a decent speed), it would be faster to figure out graphics & IO in some other platform than performance in GameMaker. GameMaker's general lack would also frustrate you no end if you did try to implement HashLife, which is not exactly simple, imho.
Logged
Super-Dot
Level 1
*


hup hup


View Profile
« Reply #2 on: May 01, 2009, 02:30:05 PM »

Dude, you are a CS student and writing Life in GameMaker?
Life itself I wouldn't mind doing in some other language (heck, if I make a DLL I'll have to learn C++ (which, in turn, means learning C) first), but everything surrounding it works better in Game Maker. This particular game has a bunch of tricky design issues, and Game Maker makes it easy to iterate-iterate-iterate and slap on features.

Use some other language (say something that actually supports arrays at a decent speed), it would be faster to figure out graphics & IO in some other platform than performance in GameMaker. GameMaker's general lack would also frustrate you no end if you did try to implement HashLife, which is not exactly simple, imho.
That's the idea behind DLLs and Extensions, I think. You write something in a different language and plug it in.
Logged

Kelsey Higham, student at SJSU
Mikademus
Level 10
*****


The Magical Owl


View Profile
« Reply #3 on: May 01, 2009, 04:26:58 PM »

To make DLLs that runs decently you'll have to learn another language anyway, and if you want the more efficient arrays they'll have to be in the DLLs and then you've already done the entire game in another language anyway.

Save yourself the grief and code it in a suitable language from the start already. Also, as a CS student you should have already learned at least one proper language, and if you haven't see this as an excuse?  Giggle
Logged

\\\"There\\\'s a tendency among the press to attribute the creation of a game to a single person,\\\" says Warren Spector, creator of Thief and Deus Ex. --IGN<br />My compilation of game engines for indies
Super-Dot
Level 1
*


hup hup


View Profile
« Reply #4 on: May 01, 2009, 07:14:10 PM »

I know that other languages are useful, but the vast majority of this project works better in Game Maker than in a proper language. That's why I'm asking about teaming up a proper language with Game Maker. Wink

To make DLLs that runs decently you'll have to learn another language anyway
Cool! Should I try to do it in C, or would it be smarter to learn C++ or C# or something first?

and if you want the more efficient arrays they'll have to be in the DLLs
That is my intention! My question is how I should go about doing this. Right now I have two ds_grids from which I read values to spawn blocks. How do DLLs interact with GML? How can I make them interact without needing a two-dimensional for loop in Game Maker? And where should I start?
Logged

Kelsey Higham, student at SJSU
Mikademus
Level 10
*****


The Magical Owl


View Profile
« Reply #5 on: May 02, 2009, 10:23:48 AM »

Quick reply: if the only thing you need in the DLL is the 2D array things, and they are quite low-level, then go with C. It is an easy to understand procedural language, and the DLL handling are virtually identical for both C and C++ under Windows.
Logged

\\\"There\\\'s a tendency among the press to attribute the creation of a game to a single person,\\\" says Warren Spector, creator of Thief and Deus Ex. --IGN<br />My compilation of game engines for indies
Shuger
Level 0
**


View Profile
« Reply #6 on: May 03, 2009, 03:45:08 AM »

Since i don't know game maker i may sound really stupid and talking false things, but if 1D arrays are faster then 2D in game maker (if they are, i don't now Tongue ), then why don't you go with 1d? It's pretty simple instead of doing array
  • [y] you do array[y*witdh + x]. But as i said i don't know anything about game maker so... ingnore me   Roll Eyes
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #7 on: December 11, 2009, 11:45:47 AM »

could you post the code? it's hard to suggest optimizations without seeing that.
Logged

Pishtaco
Level 10
*****


View Profile WWW
« Reply #8 on: December 11, 2009, 12:04:03 PM »

If you're just using it for graphics, then it's conceivable that you could do the whole thing on a grid of pixels in the graphics card using surfaces and blend modes.
Logged

ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #9 on: December 11, 2009, 12:43:51 PM »

that'd be even slower -- draw_getpixel() is a notoriously slow game maker function, consuming around 800 microseconds / 0.8 milliseconds for each use. most of game maker's functions cost 2 microseconds / 0.002 milliseconds.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic