Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

877483 Posts in 32868 Topics- by 24305 Members - Latest Member: orloff

May 19, 2013, 03:48:02 PM
TIGSource ForumsDeveloperTutorialsGame Maker Tuts
Pages: 1 ... 17 18 [19] 20 21 ... 29
Print
Author Topic: Game Maker Tuts  (Read 126667 times)
phubans
Indier Than Thou
Level 10
*


TIG Mascot


View Profile WWW Email
« Reply #270 on: November 23, 2010, 10:45:53 PM »

Damn, I just found out that Chevy's surface thing doesn't like GM's built in save & load feature Sad

When trying to load:

Code:
___________________________________________
ERROR in
action number 1
of Begin Step Event
for object objScreen:

Trying to use non-existing surface.
Logged

Paint by Numbers
Guest
« Reply #271 on: November 24, 2010, 10:29:22 PM »

Damn, I just found out that Chevy's surface thing doesn't like GM's built in save & load feature Sad

Yeah, GM doesn't save surfaces. I don't think there's a lot one can do about it. Undecided
Logged
GZ
Level 1
*



View Profile WWW Email
« Reply #272 on: November 24, 2010, 11:21:13 PM »

I'm not sure how well it would perform, because I don't use GM's built in saving so I never had this issue, but you could use a surface checking code before drawing to the surface. IE.

Begin step:
if (surface_exists(surface)==0) surface_create(); //
//draw to surface code

I'm not sure how much that would effect performance, but it should solve that problem.
Logged

caiys
Level 10
*****



View Profile WWW
« Reply #273 on: November 25, 2010, 01:13:34 AM »

I'm pretty sure Spelunky uses Chevy's surface scaling and GMs inbuilt save/load so you might want to check out its source code phubans.
Logged

pgil
Guest
« Reply #274 on: November 25, 2010, 07:24:12 AM »

I think Spelunky just uses the built-in high score table to save stats. I thought Phubans was talking about the save_game() function that works like the save-states in emulators.
Logged
GZ
Level 1
*



View Profile WWW Email
« Reply #275 on: November 26, 2010, 12:01:31 AM »

I've created an example using Chevy's scaling code with some minor alterations:

http://gzstorm.com/gmhelp/SurfaceRestore0.gmk

It makes sure to always recreate the surface if it doesn't exist. This should fix your problem with GM's save system.
Logged

MegaLeon
Level 0
***



View Profile WWW
« Reply #276 on: November 28, 2010, 04:13:52 PM »

Hey guys, I'm trying to create an object in a random position in a 16x16 grid, making sure that it doesn't overlap a wall. I tought that this code might do the trick, but it doesn't look like it works. Can anyone help me?

Code:
repeat (5)
{
var xx,yy
xx = round(random(room_width/16))*16
yy = 32 + round((random_height - 64)/16)*16
while not place_empty(xx,yy)
{
xx = round(random(room_width/16))*16
yy = 32 + round((random_height - 64)/16)*16
}
instance_create(xx,yy,obj_treasure)
}

32px on the top and 32px on the bottom are reserved for UI
Logged

GZ
Level 1
*



View Profile WWW Email
« Reply #277 on: November 28, 2010, 10:55:05 PM »

The object that is executing the code to place the 5 objects is being checked for collision, not obj_treasure. Think about that for a moment. So the sprite mask of the object calling that code is being used, and if that object has no sprite (I assume this is why it's not working) there will always be no collision. So there are two solutions:

- Set the sprite of the object using that code to obj_treasures. This is not the recommended solution as it's a quick fix and not a proper way to do it, especially if you plan to use other generating for objects with larger collision boxes.

- Use this code instead:

Code:
repeat (5) {
 obj=instance_create(0,0,obj_treasure);
 with (obj) {
  x = round(random(room_width/16))*16;
  y = 32 + round((random_height - 64)/16)*16;
  while not place_empty(x,y) {
   x = round(random(room_width/16))*16
   y = 32 + round((random_height - 64)/16)*16
  }
 }
}

It uses the treasure object itself to check for collisions.
Logged

MegaLeon
Level 0
***



View Profile WWW
« Reply #278 on: November 29, 2010, 09:38:17 AM »

The object that is executing the code to place the 5 objects is being checked for collision, not obj_treasure. Think about that for a moment. So the sprite mask of the object calling that code is being used, and if that object has no sprite (I assume this is why it's not working) there will always be no collision. So there are two solutions:

- Set the sprite of the object using that code to obj_treasures. This is not the recommended solution as it's a quick fix and not a proper way to do it, especially if you plan to use other generating for objects with larger collision boxes.

- Use this code instead:

Code:
repeat (5) {
 obj=instance_create(0,0,obj_treasure);
 with (obj) {
  x = round(random(room_width/16))*16;
  y = 32 + round((random_height - 64)/16)*16;
  while not place_empty(x,y) {
   x = round(random(room_width/16))*16
   y = 32 + round((random_height - 64)/16)*16
  }
 }
}

It uses the treasure object itself to check for collisions.

Epic crash. I think there's something wrong with the while statement.
Logged

phubans
Indier Than Thou
Level 10
*


TIG Mascot


View Profile WWW Email
« Reply #279 on: November 29, 2010, 11:49:29 AM »

Hmm, basically sometimes it works and other times it doesn't. I think I got that error because I tried to load something from a previous build of the game after I had changed something.
Logged

GZ
Level 1
*



View Profile WWW Email
« Reply #280 on: November 29, 2010, 12:10:35 PM »

Epic crash. I think there's something wrong with the while statement.
I didn't read over the code because I had assumed it was correct, but there were two problems. Namely, there was a value called random_height instead of room_height. I think you meant to put random(room_height because you are also missing the random function for the Y axis. I've created an example with fixed code:

http://gzstorm.com/gmhelp/TreasureGenerate.gmk

Check the game info for details.
Logged

GZ
Level 1
*



View Profile WWW Email
« Reply #281 on: November 29, 2010, 12:15:41 PM »

Hmm, basically sometimes it works and other times it doesn't. I think I got that error because I tried to load something from a previous build of the game after I had changed something.
Using GM's built-in save, you really shouldn't do this. The built-in save really only works properly on the exact same version it was made. Technically it can still load, but expect to see problems much like the surface one you experienced. This is why the built-in save is usually not used.

You can still use the built-in save, but save files will not transfer correctly when you update your game. For a short game this might work, since people will not care much about saves carrying over, and most likely you won't need to release many updates if you ensure your final version is fairly bug free. Using the GM save is handy but not always ideal.

What exactly do you need saving in your game? It might not be as complicated as you think. Basically, what kind of game are you making, and when can the user save (checkpoints, between levels, anytime)?
Logged

xerus
Vice President of Marketing, Romeo Pie Software
Level 10
*


kpulv

Storm+X+MH
View Profile WWW
« Reply #282 on: November 29, 2010, 08:19:21 PM »

Unless you absolutely need to save the exact state of the game I would avoid using the built in save function and just write what you need to save to a file.
Logged

MegaLeon
Level 0
***



View Profile WWW
« Reply #283 on: November 30, 2010, 07:09:18 AM »

Epic crash. I think there's something wrong with the while statement.
I didn't read over the code because I had assumed it was correct, but there were two problems. Namely, there was a value called random_height instead of room_height. I think you meant to put random(room_height because you are also missing the random function for the Y axis. I've created an example with fixed code:

http://gzstorm.com/gmhelp/TreasureGenerate.gmk

Check the game info for details.

Thanks for the help and for the hassle, GZ!
I realized that my wall sprite had more than one subimage, so it was crashing during the loop because the mask changed continuosly.
Logged

caiys
Level 10
*****



View Profile WWW
« Reply #284 on: December 10, 2010, 09:49:43 AM »

I seem to be having some strange oddities using Chevy's surface scaling. On some random objects it seems to crunch or expand a pixel line. You can see it on the speech bubble below.

Gah! This is getting really annoying now. Just started a new game and am getting the same problems. The image on the left is what I'm seeing in-game while it should look like the right pic.



I threw up the gmk here and it's really early in the dev so it should be easy to rummage around in there. I'd really appreciate it if somebody could open it up and take a look just so I know if my graphics card is at fault or the game itself. If it's just my graphics card then I can ignore it since I have a pretty old-ish GeForce so hopefully very few people will suffer from it.

//edit
GZ solved it.
« Last Edit: December 10, 2010, 01:34:04 PM by caiys » Logged

Pages: 1 ... 17 18 [19] 20 21 ... 29
Print
Jump to:  

Theme orange-lt created by panic