ஒழுக்கின்மை (Paul Eres)
|
|
« Reply #80 on: December 12, 2008, 12:49:21 PM » |
|
Here's a hint for doing that: use real() and string() and save as a string, rather than the way the manual recommends, because there are rounding errors, so if you don't do that you could tell it to save '2' and it'd be written to file as 1.9999999999993432874434 or something.
|
|
|
Logged
|
|
|
|
JasonPickering
|
|
« Reply #81 on: December 12, 2008, 01:04:23 PM » |
|
so i would write the variable to a string, then when loading write the string to the variable.
|
|
|
Logged
|
|
|
|
GregWS
|
|
« Reply #82 on: December 12, 2008, 01:09:03 PM » |
|
Here's a hint for doing that: use real() and string() and save as a string, rather than the way the manual recommends, because there are rounding errors, so if you don't do that you could tell it to save '2' and it'd be written to file as 1.9999999999993432874434 or something.
Huh, interesting. Thanks rinku; I'll keep that in mind, as I'm sure I'll be doing my own save systems again.
|
|
|
Logged
|
|
|
|
Matt Thorson
|
|
« Reply #83 on: December 12, 2008, 02:46:35 PM » |
|
Here's a hint for doing that: use real() and string() and save as a string, rather than the way the manual recommends, because there are rounding errors, so if you don't do that you could tell it to save '2' and it'd be written to file as 1.9999999999993432874434 or something.
I think this was fixed in v7.0. Could be wrong though.
|
|
|
Logged
|
|
|
|
ஒழுக்கின்மை (Paul Eres)
|
|
« Reply #84 on: December 12, 2008, 02:53:30 PM » |
|
I don't think it was, I had the same problem even in 7.0.
|
|
|
Logged
|
|
|
|
salade
|
|
« Reply #85 on: December 17, 2008, 11:40:13 AM » |
|
can anyone explain how to use instance id? i'm working through, but it's confusing.
|
|
|
Logged
|
|
|
|
ஒழுக்கின்மை (Paul Eres)
|
|
« Reply #86 on: December 17, 2008, 02:39:12 PM » |
|
Um, you just use it. Could you be more clear on what you mean? Your question is like asking "how do I use variables" or something.
If you're asking what the syntax is, you just use the dot. First you store the instance id in a variable, this can happen when you create the instance, or you can just use id from within an instance.
After you've stored the instance id in a variable (let's call it instanceid), you can then use it: i.e. 'instanceid.x = 100;' will set an instance's x to 100.
Also, 'with(instanceid)' will perform some code as if you were performing it from within the instance. For instance, 'with(instanceid) instance_destroy();' would destroy that instance.
|
|
|
Logged
|
|
|
|
salade
|
|
« Reply #87 on: December 27, 2008, 03:29:31 PM » |
|
thanks! I just finished a buch of code that used instance id's, and your advice came in handy.
|
|
|
Logged
|
|
|
|
JasonPickering
|
|
« Reply #88 on: January 03, 2009, 01:11:44 AM » |
|
oh gamemaker gods I bessech you.
first. what is the proper spelling of beseech?
second. i am having some code trouble. when a player collides with this empty patch of dirt, flowers sprout. I have a 6 frame animation of the flowers growing. the problem is it never stops. it jsut loops the animation over and over again.
here is the gml I am using.(variable grow is set to 0 on create)
called during a collision event
if grow=0 { grow=1 image_alpha=1 sprite_index=spr_grow_middle image_speed=.1 }
if image_index=5 { image_speed=0 }
|
|
|
Logged
|
|
|
|
Terry
|
|
« Reply #89 on: January 03, 2009, 01:32:23 AM » |
|
Well, basically, that's only being called when there's a collision. The initial collision causes the animation to start, but to check that it's ended you need to put this bit:
if image_index=5 { image_speed=0 }
into a step function, or possibly if there's some kind of animation end event you could put it there.
|
|
|
Logged
|
|
|
|
TeeGee
|
|
« Reply #90 on: January 03, 2009, 01:41:09 AM » |
|
first. what is the proper spelling of beseech? Beseech. second. i am having some code trouble. when a player collides with this empty patch of dirt, flowers sprout. I have a 6 frame animation of the flowers growing. the problem is it never stops. it jsut loops the animation over and over again.
here is the gml I am using.(variable grow is set to 0 on create)
called during a collision event
if grow=0 { grow=1 image_alpha=1 sprite_index=spr_grow_middle image_speed=.1 }
if image_index=5 { image_speed=0 }
Okay, for starters why the image_index check is done within the collision event? In that case it will only apply if the player still collides with the patch of dirt. If he will lose contact before the animation ends, the animation will loop endlessly. As for the main problem, it's caused by inaccuracy. Image_index will probably never be exactly 5 to make the if statement true. You could replace it with... if floor(image_index)=5 { image_speed=0 } and put it within the step event of the patch object. Or you could do it the right way and just create animation end event (it's within other category) in the patch object and put this there: image_speed=0 The second solution is more optimal.
|
|
|
Logged
|
|
|
|
Terry
|
|
« Reply #91 on: January 03, 2009, 01:59:32 AM » |
|
As for the main problem, it's caused by inaccuracy. Image_index will probably never be exactly 5 to make the if statement true. You could replace it with...
I'm no expert on how game maker works, but I'd be pretty surprised if that was true...
|
|
|
Logged
|
|
|
|
TeeGee
|
|
« Reply #92 on: January 03, 2009, 02:29:59 AM » |
|
It is true. I was pretty surprized at first too. One of the GM's biggest problems imho is that it doesn't really leave the choice of having a value as a float or integer to the user. And it uses floats for most stuff. It sometimes causes problems with inaccuracy if you are not aware of that.
image_speed is a float value that is added to image_index every step. It gets inaccurate after few cycles. I just ran a simple test to make sure I'm not telling bullshit. I set image_speed to 0.1 and started watching image_index in debug mode. After few cycles of it going normally: 0.10, 0.20, 0.30... I started getting 0.100000, 0.200000, 0.300000, meaning that there was some inaccuracy several places after the coma. if(image_index=5) statement was never true.
|
|
|
Logged
|
|
|
|
JasonPickering
|
|
« Reply #93 on: January 03, 2009, 11:35:37 AM » |
|
thanks guys. using the animation end event worked perfectly. now onto the task of switching the main characters sprites, when he does different things. WEEE
|
|
|
Logged
|
|
|
|
JasonPickering
|
|
« Reply #94 on: January 03, 2009, 08:22:18 PM » |
|
hey guys, having some more problems.
my player can be sucked into a pipe as a warp. so here is the code I have.
basically the player hits the button and a new object is placed with him being sucked into the warp pipe. at the end of the animation I have it check to see where he should be spanwned. right he switches between the two spots, the problem is that if the third part spwans player is active, then it ignores the first to parts and skips right to spawning the player. I added the switching of global.warpto=0 cause I hoped it would send him through once, then when that animation was over it would redo the animation end event this time spawning the player.
animation end event:
//Warps to A if global.warpto=1 { x=obj_warp_a.x y=obj_warp_a.y image_index=7 image_speed=-.5 global.warpto=5 }
//Warps to B if global.warpto=2 { x=obj_warp_b.x y=obj_warp_b.y image_index=7 image_speed=-.5 global.warpto=5 }
// spawns player
if global.warpto=5 { instance_create(obj_char_warp.x,obj_char_warp.y,obj_char) instance_destroy() }
|
|
|
Logged
|
|
|
|
SirNoodles
|
|
« Reply #95 on: January 27, 2009, 07:00:04 PM » |
|
I seem to be running into a big problem. My room is 320x240, and the scale is 2. I have an object that is persistent, and is in its own room. It run the three scripts. After, it goes to the next room. The room itself has no view properties, and then next room only has views enabled. Skullpogo works just fine for me, so it's not the videocard, and I haven't edited the scripts at all. What it does is render everything at 4x scale instead of 2x, but in a 640x480 window.It renders in the top left corner, like so: It should look like this I'll be happy to answer any questions, and thanks for the help. P.S. Heres the gm6 if that'll help: http://www.rocketsoft.gm-school.uni.cc/uploads/scalingepicfail.gm6Thanks ChevyRay!
|
|
|
Logged
|
|
|
|
Neo1493
|
|
« Reply #96 on: January 28, 2009, 12:57:02 AM » |
|
image_speed is a float value that is added to image_index every step. It gets inaccurate after few cycles. I just ran a simple test to make sure I'm not telling bullshit. I set image_speed to 0.1 and started watching image_index in debug mode. After few cycles of it going normally: 0.10, 0.20, 0.30... I started getting 0.100000, 0.200000, 0.300000, meaning that there was some inaccuracy several places after the coma. if(image_index=5) statement was never true.
Thats odd I have gamemaker 7 and I dont have this problem or maby I do and dont relise it quick to thecodeing cave batman
|
|
|
Logged
|
|
|
|
Xion
|
|
« Reply #97 on: January 28, 2009, 10:12:14 PM » |
|
that definitely happens for me.
|
|
|
Logged
|
|
|
|
Juju
|
|
« Reply #98 on: January 31, 2009, 12:46:15 PM » |
|
I started getting 0.100000, 0.200000, 0.300000, meaning that there was some inaccuracy several places after the coma.
Solution: image_index = floor(image_index*10)/10;. I'm surprised GM7 is generating inaccuracies as Mark Overmars fixed the old and very poor accuracy, how many steps did it take for this problem to appear?
|
|
|
Logged
|
|
|
|
Dugan
|
|
« Reply #99 on: February 02, 2009, 02:23:04 AM » |
|
Hi there - well I tried your file, "scalingepicfail.gm6" and it all looks normal to me. (like the pic above - everything is in view). As the file ends in gm6 I am assuming you are using gamemaker6? I have 7, maybe try dloading 7 and see if fixes the problem on your machine. EDIT - if i unclick `enable use of views` in the room settings - i get the error where your game appears too zoomed in (as per your 1st screenshot). But reclicking `enable use of views` fixes it all once again. I`d suggest to try your game on a few other pcs if at all possible.
|
|
« Last Edit: February 02, 2009, 05:59:08 AM by moogled »
|
Logged
|
|
|
|
|