Go to page Previous  1, 2, 3, 4, 5 ... 41  Next  [ 816 posts ]  Reply to topicPost new topic 
Coding Help, Questions and Issues relating to coding
Author Message
 [us]
 Post subject: Re: Coding Help
PostPosted: Sat Mar 30, 2013 1:04 am 
User avatar
Pootis
Member
[*]
[*]
[*]
[*]
Check if vspeed > 0, if true, set the sprite to your falling sprite. Simple as that.

_________________
Nothing really to put here.
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Sat Mar 30, 2013 9:22 am 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
Quotient wrote:
Check if vspeed > 0, if true, set the sprite to your falling sprite. Simple as that.


Thanks Quo

_________________
Spoiler:
 
Top
Offline 
 
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Tue Apr 02, 2013 2:41 pm 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
Another question...

How do you make a Bill Blaster detect whether Mario (or Luigi) is to its left or right?

DnD, please. (Standard edition)

_________________
Spoiler:
 
Top
Offline 
 
 
 [br]
 Post subject: Re: Coding Help
PostPosted: Tue Apr 02, 2013 3:36 pm 
User avatar
Not a bird
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
You can center the sprite x or use this:
if obj_player.x > x+sprite_width/2
{
//the right facing! Place your code here...
}
else
{
//Left facing! Your code goes here...
}

_________________
Please contact me for any broken links below.
Spoiler:

Spoiler:
 
Top
Offline 
 
 
 [jp]
 Post subject: Re: Coding Help
PostPosted: Tue Apr 02, 2013 4:01 pm 
User avatar
Yeah, I don't Even...
Member
[*]
[*]
[*]
[*]
[*]

[*]
or you could do this:

Code:
//--Creation Event--
//Variable Initialization
facing=0;alarm[0]=60;//Change alarm number if needed

//--Alarm[0] Event--
if obj_player.x>=self.x{facing=-1;}
else if obj_player.x<=self.x+16{facing=1;}
else if obj_player.x<=self.x && obj_player.x >=self.x+16{facing=0;}
if facing=0{alarm[0]=60;exit;}
else if facing!=0{ii=instance_create(x,y,obj_bullet);ii.hspeed=2*facing;ii.type=1/*used for if you want to have a homing bill or not*/}
alarm[0]=60;

just substitute obj_player with what ever the player parent is.
and substitute obj_bulet for what ever the bullet bill object's name is.

This isn't in DnD because DnD is extremely inefficient and can take more time than needed.

_________________
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Tue Apr 02, 2013 4:46 pm 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
or you could do this:

Code:
//--Creation Event--
//Variable Initialization
facing=0;alarm[0]=60;//Change alarm number if needed

//--Alarm[0] Event--
if obj_player.x>=self.x{facing=-1;}
else if obj_player.x=self.x+16{facing=0;}
if facing=0{alarm[0]=60;exit;}
else if facing!=0{ii=instance_create(x,y,obj_bullet);ii.hspeed=2*facing;ii.type=1/*used for if you want to have a homing bill or not*/}
alarm[0]=60;

just substitute obj_player with what ever the player parent is.
and substitute obj_bulet for what ever the bullet bill object's name is.

This isn't in DnD because DnD is extremely inefficient and can take more time than needed.


crap I'm making my platformer in DnD :(

My engine isn't really buggy though - just one graphics glitch.

Thanks anyway

_________________
Spoiler:
 
Top
Offline 
 
 
 [gb]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 10, 2013 12:51 pm 
User avatar
Gold 'n Syrup
Member
[*]
I'm trying to animate my character so when he stops moving he goes back to standing.
Only problem is when you release the 'D' key (going right) he changes to standing.
but when you release the 'A' key (going left) he does animate but stays in the walk sprite.

Here's the code.
Spoiler:

_________________
Image
 
Top
Offline 
 User page at mfgg.net
 
 [jp]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 10, 2013 3:17 pm 
User avatar
Yeah, I don't Even...
Member
[*]
[*]
[*]
[*]
[*]

[*]
Farlon303 wrote:
I'm trying to animate my character so when he stops moving he goes back to standing.
Only problem is when you release the 'D' key (going right) he changes to standing.
but when you release the 'A' key (going left) he does animate but stays in the walk sprite.

Here's the code.
Spoiler:

Well the problem is that you simply made it change it's frame.

Before I give you some help on it, what are you trying to accomplish with it, a description on how it walks and such would be helpful. So I know what your trying to do.)

_________________
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 10, 2013 4:01 pm 
User avatar
Gold 'n Syrup
Member
[*]
Shadow Kami wrote:
Spoiler:

Well the problem is that you simply made it change it's frame.

Before I give you some help on it, what are you trying to accomplish with it, a description on how it walks and such would be helpful. So I know what your trying to do.)[/spoiler]


Well it's a platforming character who moves left and right so (as I wanted) when you press the 'D' key he moves to the right and changes to an animated sprite. And it's the same with the left movement.

I want it so when the character stops moving he changes from his walking sprite back to his standing still sprite.
Now when 'D' is released and the character stops moving he changes back to his standing sprite but when
'A' is released he stops moving but stays in the walking left sprite.

_________________
Image
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 10, 2013 4:15 pm 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
That code doesn't make much sense - that "else" is taking into consideration only the very first line. Try moving the ifs that are inside braces to be just outside them, like so:
Code:
if !keyboard_check(ord('A')) && !keyboard_check(ord('D')) && !keyboard_check(ord('W')) // Checks if A, D and W aren't being pressed.
{
if keyboard_check_released(ord('D')) // If D was released
{
sprite_index = spr_player // Set to still sprite
image_index = 0 // Set player to face RIGHT
}
else if keyboard_check_released(ord('A')) // if A was released
{
sprite_index = spr_player //Set to still sprite
image_index = 1 // Set player to face LEFT
}
}


I can still see this acting kind of funky but this should fix the immediate issue.

_________________
"talk about dang ol' this ain't scientific rockets, man"
Spoiler:
Bibby Team - Nice little place. Give it a try.
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 10, 2013 4:19 pm 
User avatar
Gold 'n Syrup
Member
[*]
Miles wrote:
Spoiler:


Worked like a charm! Thanks a bunch :D

_________________
Image
 
Top
Offline 
 User page at mfgg.net
 
 [jp]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 10, 2013 4:23 pm 
User avatar
Yeah, I don't Even...
Member
[*]
[*]
[*]
[*]
[*]

[*]
Stop deing so darn fast miles, I was going to post something that isn't so wonkily coded.

Also, the absense of semicolons makes me cry. D:

_________________
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Mon Apr 22, 2013 8:38 pm 
User avatar
meow
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
I've been wanting to know this for a while - how do you use spritefonts?

 
Top
Offline 
 User page at mfgg.net
 
 [tw]
 Post subject: Re: Coding Help
PostPosted: Mon Apr 22, 2013 10:15 pm 
福瑞退化者
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
All of the sprites must be in order ASCII, which is viewed in order in "Character Map" [Type charmap in run]

_________________
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Sat Apr 27, 2013 8:46 pm 
User avatar
meow
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
I'm not sure if this is coding, but I still need help with it.

A screen of my fangame imitates a DS. The size of the view is 320x480. I'm trying to get the character on the top screen to stay on the top screen. Right now, he is going into the bottom screen and behind an object due to depths, making him no longer visible. Help?

Here's more info:

View in room:
X - 0
Y - 0
W - 340
H - 480

Port on screen:
X - 0
Y - 0
W - 340
H - 480

Object following:
(player character)
Hbor - 320
Vbor - 160
Hsp - -1
Vsp - -1

 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Thu May 09, 2013 9:38 am 
User avatar
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
Can't you set the first (top-view) on the player and the second (bottom-view) on a certain position in the room? For example, you say the player is not supposed to be able to appear on the bottom-view, so why not set the bottom-view's (x,y) in a place in the room where the player cannot reach (x,y) = (0,0) and have the actual level appear else where.

 
Top
Offline 
 
 
 [nl]
 Post subject: Re: Coding Help
PostPosted: Thu May 09, 2013 11:06 am 
User avatar
Wreck 'n get stomped
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
If it's a platformer, place solids at the top of the bottom screen, but that's not the ultimate solution, I think. Or, just make 2 views.

_________________
My Youtube | My Twitter
 
Top
Offline 
 User page at mfgg.net
 
 [br]
 Post subject: Re: Coding Help
PostPosted: Thu May 09, 2013 6:40 pm 
User avatar
Not a bird
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
Just make a Sprite for the player jumping in the first frame and in the second frame the one that shows him falling.
Then add the code:
Code:
if keyboard_press(*insert jump button*)
{
*insert jumping code*
jump = 1
}
if jump = 1
{
if vspeed < 0
image_index = 0
else
image_index = 1
}

Don't forgot to do the "jump" variable turns into 0 when player lands in ground!

_________________
Please contact me for any broken links below.
Spoiler:

Spoiler:
 
Top
Offline 
 
 
 [gb]
 Post subject: Re: Coding Help
PostPosted: Wed May 15, 2013 7:15 pm 
I never really was on your side.
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
For anyone with Xbox Controller experience with Game Maker:

I am adding in Xbox Controller support to my game, but I have situations where I'm substituting joystick_check_button(id,button) for keyboard_check_pressed() but joystick_check_button(x,y) acts like keyboard_check(). Does anyone have a solution to having it act like keyboard_check_pressed()?

 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed May 15, 2013 7:25 pm 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Have a bunch of control variables in your object. Let's say ControlA is the A button.
Code:
if joystick_check_button(1,1) ControlA=min(2,ControlA+1);else if ControlA>0 ControlA=-1;else ControlA=0;

If it's equal to 1, it was just pressed. If it's 1 or more, it is being held. If it's -1, it was just released. If it's 0, it hasn't been pressed lately.


Last edited by Miles on Sun May 19, 2013 1:32 am, edited 1 time in total.
updated because oops

_________________
"talk about dang ol' this ain't scientific rockets, man"
Spoiler:
Bibby Team - Nice little place. Give it a try.
 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
Go to page Previous  1, 2, 3, 4, 5 ... 41  Next  [ 816 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group