Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1] 2   Go Down

Author Topic: [Request / Listing] GML Code help  (Read 6039 times)

0 Members and 1 Guest are viewing this topic.
[Request / Listing] GML Code help
« on: May 21, 2006, 06:57:44 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
I need help just a little bit of help shouldn't be much of a task,

I want a sprite to change to something when thE animation is finished

I set it up so's that in the object properties after animation ends it executes a script but what code should I put into this script to change the sprite i've checked the help file and it was no help :(
« Last Edit: March 06, 2012, 08:38:28 am by Niek »
Logged

Goodnight

Once and future Captain
Re: GML Code help
« Reply #1 on: May 21, 2006, 07:42:32 pm »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
if sprite_index=old_sprite sprite_index=new_sprite
Logged
Re: GML Code help
« Reply #2 on: May 21, 2006, 08:29:34 pm »
  • Huzzowee!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 571
you need a semicolon (";") between them though, no?

if sprite_index=old_sprite; sprite_index=new_sprite

like that?
Logged
"They say 'Don't sweat the little things!', but in the end, the little things are all that matter..."
--Alex2539
Re: GML Code help
« Reply #3 on: May 21, 2006, 08:39:12 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
Well I tried that and this came up;

Logged

dylan623

Re: GML Code help
« Reply #4 on: May 21, 2006, 08:43:16 pm »
I need help just a little bit of help shouldn't be much of a task,

I want a sprite to change to something when thE animation is finished

I set it up so's that in the object properties after animation ends it executes a script but what code should I put into this script to change the sprite i've checked the help file and it was no help :(
If you're new to GM, just use D&D. How many times do I have to say that?
Logged
Re: GML Code help
« Reply #5 on: May 21, 2006, 08:44:48 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
if sprite_index=old_sprite{sprite_index=new_sprite}
« Last Edit: May 21, 2006, 08:47:10 pm by 4Sword »
Logged
Re: GML Code help
« Reply #6 on: May 21, 2006, 08:45:10 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
I need help just a little bit of help shouldn't be much of a task,

I want a sprite to change to something when thE animation is finished

I set it up so's that in the object properties after animation ends it executes a script but what code should I put into this script to change the sprite i've checked the help file and it was no help :(
If you're new to GM, just use D&D. How many times do I have to say that?

Firstly im guess D&D means Drag and Drop Secondly ive actually only heard you say that once, but thst because im about as active as a dead fly, and thirdly, I just wanna learn GML so badly that im just gonna start with it and sod D&D
Logged
Re: GML Code help
« Reply #7 on: May 21, 2006, 08:46:56 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
if sprite_index=old_sprite {sprite_index=new_sprite}


Dude, thanks so much ^.^
Logged

dylan623

Re: GML Code help
« Reply #8 on: May 21, 2006, 08:49:41 pm »
I need help just a little bit of help shouldn't be much of a task,

I want a sprite to change to something when thE animation is finished

I set it up so's that in the object properties after animation ends it executes a script but what code should I put into this script to change the sprite i've checked the help file and it was no help :(
If you're new to GM, just use D&D. How many times do I have to say that?

Firstly im guess D&D means Drag and Drop Secondly ive actually only heard you say that once, but thst because im about as active as a dead fly, and thirdly, I just wanna learn GML so badly that im just gonna start with it and sod D&D
Don't try to run before you can walk, I still use mainly D&D.
Logged
Re: GML Code help
« Reply #9 on: May 21, 2006, 08:51:18 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
I understand what ya gettin at, I may turn to using D&D aswell, But i'd prefer to try and code it. I love challanges :P
Logged
Re: GML Code help
« Reply #10 on: May 21, 2006, 08:53:54 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
I cannot remember if there is supposed to be a space before the first bracket thingy, but that is how I would set it up.  Are you setting it up for just changing after one type of sprite is done, or is there more than one sprite?  If there are more, if would look like this:

switch(sprite_index){
case(old_sprite1):sprite_index=new_sprite1; break;
case(old_sprite2):sprite_index=new_sprite2; break;
case(old_sprite3):sprite_index=new_sprite3; break;
case(old_sprite4):sprite_index=new_sprite4; break;
}

It is good to try and run before you walk.  It shows ambition and lack of fear.  Those who often start out running never fear falling down because they go through it a lot, and in the end they are stronger for it.
Logged
Re: GML Code help
« Reply #11 on: May 21, 2006, 08:55:04 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
It is good to try and run before you walk.  It shows ambition and lack of fear.  Those who often start out running never fear falling down because they go through it a lot, and in the end they are stronger for it.

... What he said :P
Logged

dylan623

Re: GML Code help
« Reply #12 on: May 21, 2006, 08:59:11 pm »
It is good to try and run before you walk.  It shows ambition and lack of fear.  Those who often start out running never fear falling down because they go through it a lot, and in the end they are stronger for it.

... What he said :P
It still helps to understand what you're doing. If you understand D&D first, you will be able to code better.
Logged
Re: GML Code help
« Reply #13 on: May 21, 2006, 09:16:06 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
The walking and running metaphor is not the best to describe the situation anyway.  It is more like having your parents drive you around before you get your license to drive and then learning how to drive.  Your parents did everything for you, so you might know what it is like to drive, you have never done it.  You could probably imagine yourself doing it, but not all of it.  When you learn to drive, you quickly realize that it is not simply push pedal and turn wheel.  There are other factors you have to learn.  The whole fact that someone did something for you does not give you the progresses ability to do something.

In other words,  while D&D may be good for beginners, it really does not help you to go into GML.  If you were a master of D&D, you would still have to learn how to set up GML.  Not only that, but GML offers more than D&D does, so even if you know all of D&D, you are still missing out on a lot of stuff.
Logged
Re: GML Code help
« Reply #14 on: May 21, 2006, 09:18:25 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
Do you have some sort of Random kick ass quote generator that no one knows about?
Logged
Re: GML Code help
« Reply #15 on: May 21, 2006, 09:20:25 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
No, everything I have said is something that I have thought of in five minutes or less. 
Logged
Re: GML Code help
« Reply #16 on: May 21, 2006, 09:21:07 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
... Dont worry you secrets safe with me  ;) :P
Logged

dylan623

Re: GML Code help
« Reply #17 on: May 21, 2006, 09:41:01 pm »
The walking and running metaphor is not the best to describe the situation anyway.  It is more like having your parents drive you around before you get your license to drive and then learning how to drive.  Your parents did everything for you, so you might know what it is like to drive, you have never done it.  You could probably imagine yourself doing it, but not all of it.  When you learn to drive, you quickly realize that it is not simply push pedal and turn wheel.  There are other factors you have to learn.  The whole fact that someone did something for you does not give you the progresses ability to do something.

In other words,  while D&D may be good for beginners, it really does not help you to go into GML.  If you were a master of D&D, you would still have to learn how to set up GML.  Not only that, but GML offers more than D&D does, so even if you know all of D&D, you are still missing out on a lot of stuff.
I know you would, but you should first learn D&D then learn how to set up GML. It would be easier to learn how to set up GML if you already know D&D.
Logged
Re: GML Code help
« Reply #18 on: May 21, 2006, 09:52:45 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Like I would have liked to learn what I am going to post here by going through D&D and then going to GML.  If you start out with GML, you can start a lot faster.  You do not even have to know how to do everything.  There are programs that will break down the D&D for you.

The simple fact is that D&D is not practical, and because of its unpracticality, it is a waste of time to learn and then switch to GML.  If you are serious about Game Maker, you should go straight to GML.  The time it takes you to learn it is about the same as D&D if not less, and in the end you do not have to switch when you get constrained by limits.

I would not want to do this in D&D.  If there was a mistake in it, it would take a very long time to find the mistake in D&D
Code: [Select]
u=keyboard_check(vk_up)-keyboard_check(vk_down)
d=keyboard_check(vk_down)-keyboard_check(vk_up)
l=keyboard_check(vk_left)-keyboard_check(vk_right)
r=keyboard_check(vk_right)-keyboard_check(vk_left)
if (u||d||l||r){moving=true}else{moving=false}
if sprite_index=link_s_u||sprite_index=link_w_u||sprite_index=link_sh_u{global.dir="u"}
if sprite_index=link_s_d||sprite_index=link_w_d||sprite_index=link_sh_d{global.dir="d"}
if sprite_index=link_s_l||sprite_index=link_w_l||sprite_index=link_sh_l{global.dir="l"}
if sprite_index=link_s_r||sprite_index=link_w_r||sprite_index=link_sh_r{global.dir="r"}
if global.state="normal"{
if u&&!l&&!r{sprite_index=link_w_u}
if d&&!l&&!r{sprite_index=link_w_d}
if l&&!u&&!d{sprite_index=link_w_l}
if r&&!u&&!d{sprite_index=link_w_r}
if moving=true{
if ((u||d)&&(l||r)){movestep+=(movespeed/sqrt(2))}
else{movestep+=movespeed}
while (movestep>=1) {
movestep-=1
xstep=r-l
ystep=d-u
if place_free(x+xstep,y){x+=xstep}
if place_free(x,y+ystep){y+=ystep}
}
}
else{
movestep=0
switch (sprite_index){
case link_w_d: sprite_index=link_s_d; break;
case link_w_u: sprite_index=link_s_u; break;
case link_w_l: sprite_index=link_s_l; break;
case link_w_r: sprite_index=link_s_r; break;
}
}
}
//Sprite Correction
if xstep<0&&sprite_index=link_w_r{sprite_index=link_w_l}
if xstep>0&&sprite_index=link_w_l{sprite_index=link_w_r}
if ystep<0&&sprite_index=link_w_d{sprite_index=link_w_u}
if ystep>0&&sprite_index=link_w_u{sprite_index=link_w_d}
if xstep<0&&sprite_index=link_s_r{sprite_index=link_s_l}
if xstep>0&&sprite_index=link_s_l{sprite_index=link_s_r}
if ystep<0&&sprite_index=link_s_d{sprite_index=link_s_u}
if ystep>0&&sprite_index=link_s_u{sprite_index=link_s_d}
if sprite_index=link_s_u&&moving=true{sprite_index=link_w_u}
if sprite_index=link_s_d&&moving=true{sprite_index=link_w_d}
if sprite_index=link_s_l&&moving=true{sprite_index=link_w_l}
if sprite_index=link_s_r&&moving=true{sprite_index=link_w_r}
might as well say that the part of the code that helps with the diagonal movement was created by Goodnight.  It seems so far to be the best for the diagonal movement, so until I find anything else, it is what I use.
« Last Edit: May 21, 2006, 09:54:57 pm by 4Sword »
Logged
Re: GML Code help
« Reply #19 on: May 21, 2006, 09:54:12 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 5213
What the bloody hell does that do?
Logged
Pages: [1] 2   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.049 seconds with 74 queries.

anything