Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Resolved] Matrixes and RGSS

Status
Not open for further replies.
Why the game lags (A LOT) when it is countinuosly messing with matrixes? for example:

Code:
matrix = [[1,2],[3,4],[5,6],[1,2],[3,4],[5,6],[1,2],[3,4],[5,6],[1,2],[3,4],[5,6],[1,2],[3,4],[5,6],[1,2],[3,4],[5,6],[1,2],[3,4],[5,6]]
for i in 0...matrix.length
  matrix[i][0] = 8
end

The game lags a lot, and i need so bad to use a matrix for what i'm doeing
 
It's not a matrix, it's a multi-demsional array (yes, kindof the same, but Ruby actually has a matrix library & class).

Remember that arrays are list of other objects (class X), so you can put arrays into arrays into arrays, etc.

The game shouldn't lag from that. All it does is pass through each mini-array and assigns the first value something else. Something else is causing the lag.


Also, you might want to look into the RGSS Table class if you are only using numbers.
 
Thanks i'll take a look.
But i'm sure that is the 2d array that is causing lag, because if I use 2 1d arrays, it works normally (when its there that it should lag, since its much more painful to check in 2 arrays, one for x and another for y).
 
Well how big is this 2d Array?

I really don't see it causing lag unless it was really really bug

and yes there is a Matrix class but it is not part of the ruby standard library I'm pretty sure you can google it and get the source for it if you want
 
no thats not going to lag, I remember having a 2d array length 6 height 12 for my Tetris Attack minigame and I've seen no lag

It is something else generating the lag

Do you have
1) A Window's refresh method being called in the update method
2) Calling Bitmap#draw_text, Bitmap#hue_change or Sprite#angle= every frame or very frequently
3) Running very, very large loops
 
Ok, i'm gonna make two versions, one with 2 arrays, and one with 1 2d array and edit this post as soon as it's done (3 minutes xD)

----EDIT----
Well, Now it works xD.
I'm not gonna tell you guys what was the problem or i'll have my head pawnt :(
 
Nah, I was messing with your 2d array at the same time :P.

(This is a little off-topic but, remember the obstacle thing that i told you about in msn? I have just finished to write the code :D)
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top