MFGG phpBB Message Boards Archive https://phpbb.mfgg.net/ |
|
Coding Help https://phpbb.mfgg.net/viewtopic.php?f=10&t=14053 |
Page 41 of 41 |
Author: | TheShyestJake [ Wed Feb 15, 2017 6:53 pm ] |
Post subject: | Re: Coding Help |
I solved the problem I forgot to account the Horizontal speed of the player when checking for collision. Code: //Horizontal Collision slope_max = 10 if !place_meeting(x+sign(Hsp),y,Solid) { for (cd=0;!place_meeting(x+Hsp,y+cd,Solid) && cd<=abs(slope_max);cd+=1;) { if !place_meeting(x+Hsp,y+cd,Solid) and place_meeting(x+(Hsp),y+slope_max,Solid)//Right Here y+=cd; } } if place_meeting(x+Hsp,y,Solid) { cu = 0; while ((place_meeting(x+Hsp,y-cu,Solid) && cu <= abs(slope_max))) cu += 1; if place_meeting(x+Hsp,y-cu,Solid) { while (!place_meeting(x+sign(Hsp),y,Solid)) x+=sign(Hsp); Hsp = 0; } else { y-=cu; } } x += Hsp; Kinda knew it was something as simple as that >< Hills now behave almost exactly like they did in Yoshi's Island :P |
Author: | Gatete [ Tue Mar 28, 2017 12:49 am ] |
Post subject: | Re: Coding Help |
Well, I'm on a hurry for this. I need a code to make an object change its alpha gradually as you approach it with x object. |
Author: | Physix [ Tue Mar 28, 2017 6:21 am ] |
Post subject: | Re: Coding Help |
Gatete wrote: Well, I'm on a hurry for this. I need a code to make an object change its alpha gradually as you approach it with x object. Code: var targetobject = <insert_x_object_here>
var maxdist = <insert_how_close_object_has_to_be_to_start_appearing> image_alpha = min(max(1 - (point_distance(x,y,targetobject.x,targetobject.y)/maxdist),0),1); |
Author: | SonicZetrex [ Wed Apr 19, 2017 7:15 am ] |
Post subject: | Re: Coding Help |
I really put my effort on "pulling" effect, but I can't get the hang out of it. Even though, it is a tough code for me to deal with on "ground-only", "pull from left or right" , "cancellation to crouch" , and "the range of the pull-able block". I can gladly put the original code I've put down, but I deleted it just for the sake of the ease of frustration. Here is my code for my character: Code: ///Logistics of the Raccoon! //Get the player's input key_right = keyboard_check(vk_right); key_left = -keyboard_check(vk_left); key_up = keyboard_check(vk_up); key_down = keyboard_check(vk_down); key_jump = keyboard_check_pressed(ord('Z')); key_jump_held = keyboard_check(ord('Z')); //React to inputs if pull = false { if pullhold = false { if duck = false // If not ducking move = key_left + key_right; } } hsp = move * movespeed; if climb = false // If not in ropes... if (vsp < 10) vsp += grav; //--Duck-- if grounded = true && bounce_attack = false // If on ground but, not bouncing { if key_down && place_meeting(x,y+1,obj_wall) { duck = true move = 0 bounce_able = false } else { duck = false bounce_able = true } } //--Jump-- if (place_meeting(x,y+1,obj_wall)) { if grounded = true { if bounce_attack = false && (key_jump) && climb = false && chargeon = 0 && attack = false && pull = false{ grounded = false vsp = -jumpspeed jumpland = true } //--Tail Attack-- if keyboard_check_pressed(ord('X')) && attack = false && !key_down && !place_meeting(x+1,y,obj_pushblock_trigger) && !place_meeting(x-1,y,obj_pushblock_trigger) { attack = true sprite_index = spr_rac_spin image_speed = 0.4 instance_create(x,y,obj_tailmask) audio_play_sound(snd_player_spin,1,0) } if !keyboard_check(ord('X')) && attack = false { if chargeon = true && chargetime < 30 { chargeon = false chargetime = 0 charge = 0 } else if chargeon = true && chargetime >= 30 { attack = true sprite_index = spr_rac_chargespin image_speed = 0.4 image_index = 0 instance_create(x,y,obj_tailmask) audio_play_sound(snd_player_spin,1,0) } } } } else grounded = true //---Charging Process--- if chargeon = true && chargeready = 0 && chargetime != 30 { chargetime += 0.5 } else if chargeon = true && chargetime >= 30 { chargetime = 30 chargeready = 1 } //--Jumping Variable Check-- if (vsp < 0) && (!key_jump_held) vsp = max(vsp,-jumpspeed/4.5) //--Bouncing Ability-- if keyboard_check(ord('X')) && key_down && bounce_able = true && !place_meeting(x,y-3,obj_wall) { bounce_attack = true chargeon = false } else { bounce_attack = false } //Horizontal Collision if (place_meeting(x+hsp,y,obj_wall)) { while(!place_meeting(x+sign(hsp),y,obj_wall)) { x += sign(hsp); } hsp = 0; } if climb = false && chargeon = false x += hsp; //Vertical Collision if (place_meeting(x,y+vsp,obj_wall)) { while(!place_meeting(x,y+sign(vsp),obj_wall)) { y += sign(vsp); } { if bounce_attack = true && (vsp > 0) && place_meeting(x,y+1,obj_wall)// If Bouncing and in Air { sprite_index = spr_rac_bounced; vsp = -vsp audio_play_sound(snd_player_bounce,1,0) } else vsp = 0; if jumpland = true && place_meeting(x,y+1,obj_wall) && bounce_attack = false { jumpland = false if climb = false audio_play_sound(snd_player_land,1,0) } } } y += vsp; //Animation if climb = false // If not in a climb state { if pull = false { if attack = false // If not attacked { if chargeon = false { if (move!=0) image_xscale = move; if (place_meeting(x,y+1,obj_wall)) { if (move!=0) { if bounce_attack = true and place_meeting(x,y+1,obj_wall) sprite_index = spr_rac_bounced; else sprite_index = spr_rac_walk; image_speed = 0.15; } else { if duck = true {sprite_index = spr_rac_duck image_speed = 0;} else if bounce_attack = true and place_meeting(x,y+1,obj_wall) sprite_index = spr_rac_bounced; else sprite_index = spr_rac_stand; image_speed = 0; } } else if (vsp < 0) or (vsp > 0) { if bounce_attack = true sprite_index = spr_rac_bounce else sprite_index = spr_rac_jump } } } } } if hit = true // If attacked or hit { if image_xscale = 1 { if hurt = true { if !place_meeting(x-4,y,obj_wall) x -= 4 hurt = false } } else if image_xscale = -1 { if hurt = true { if !place_meeting(x+4,y,obj_wall) x += 4 hurt = false } } } //Prevent from going outside the room (on the side) if x < 3 x = 3 if x > room_width-3 x = room_width-3 if y < -5 y = -5 // Mask Change if bounce_attack = true && duck = false // Climb {SAME} Mask mask_index = spr_mask else if duck = true && bounce_attack = false // Crouch Mask mask_index = spr_mask_crouch else if duck = false && bounce_attack = false // Normal Mask mask_index = spr_mask //--Climb-- if (collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false)) && keyboard_check_pressed(vk_up) { climb = true // Triggers the activation to climb x = obj_rope.x+8 } if (climb) // If he is on ladder or climable object { hsp = 0; vsp = 0; jumpable = false if !keyboard_check(vk_up) || !keyboard_check(vk_down) { image_speed = 0 } sprite_index = spr_rac_climb if climbmovement = true { if keyboard_check(vk_up) { if place_free(x,y-2) image_speed = 0.15; vsp-=2 } if keyboard_check(vk_down) { if place_free(x,y+2) image_speed = 0.15; vsp+=2 } if (key_up and !collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false)) or (!collision_line(x, bbox_top, x, bbox_bottom, obj_rope, false, false)) { climb = false; jumpable = true; } } if (key_jump) { vsp = -jumpspeed jumpland = true climb = false } } if global.invincibility = 1 alarm[5] = 1; Situations: *Border Transition (Like Mega Man) *Pulling and (Pushing?) Block I'm only just a rookie of figuring things out like this... |
Author: | Ihatefiendishchain [ Tue May 16, 2017 9:45 am ] |
Post subject: | Re: Coding Help |
So, i'm trying to Make a circular Transition, i'm trying to do this an work from scratch, with Game maker 8. So, i've tried the animated sprite, but it keeps animating, even when i put image_speed=0 in Animation End Event. Is there a way to solve it? |
Author: | CatoNator [ Tue May 16, 2017 12:40 pm ] |
Post subject: | Re: Coding Help |
How exactly are you making the circular transition? With an animated sprite? If that's the case, try: Code: ///Animation end event
image_speed = 0; image_index = sprite_get_number(sprite_index)-0.01; |
Author: | Gatete [ Tue May 16, 2017 2:19 pm ] |
Post subject: | Re: Coding Help |
This might help you! This does not make use of sprites at all, it uses the draw_circle function |
Author: | Ihatefiendishchain [ Tue May 16, 2017 4:09 pm ] |
Post subject: | Re: Coding Help |
CatoNator wrote: How exactly are you making the circular transition? With an animated sprite? If that's the case, try: Code: ///Animation end event image_speed = 0; image_index = sprite_get_number(sprite_index)-0.01; Yes, i used to run that, i scrapped that method before posting, but thanks anyways. Gatete wrote: Yes, Thanks. |
Author: | SilverVortex [ Thu May 18, 2017 2:38 am ] |
Post subject: | Re: Coding Help |
I need some code for ground pounding in GMStudio please! |
Author: | littlelum [ Tue Jul 25, 2017 1:22 pm ] |
Post subject: | Re: Coding Help |
I know this is stupid, but could anyone tell how to make a sprite appear on top of another sprite instead of below? Edit: It's in gamemaker 8.1 |
Author: | kremling [ Wed Jul 26, 2017 4:04 pm ] |
Post subject: | Re: Coding Help |
littlelum wrote: I know this is stupid, but could anyone tell how to make a sprite appear on top of another sprite instead of below? Edit: It's in gamemaker 8.1 Can you provide a screenshot of what is actually happening and what is expected? SilverVortex wrote: I need some code for ground pounding in GMStudio please! If you are able to make your character jump, then a ground pound should simply be the reverse. If your player is in the air and a 'button' is pressed, the characters 'vertical speed' should move down. Gravity should not be applied to the 'vertical speed' when doing a ground pound (unless you want I suppose). |
Author: | littlelum [ Thu Jul 27, 2017 12:20 pm ] |
Post subject: | Re: Coding Help |
I'm making a frogger type game, and i'm trying to make Mario jump on top of the log Attachment:
File comment: The picture didn'w work, do this
screenshot105.png [ 6.37 KiB | Viewed 4841 times ] |
Author: | kremling [ Thu Jul 27, 2017 5:30 pm ] |
Post subject: | Re: Coding Help |
@littlelum: Make sure Mario has a depth smaller than the Log's depth. So, Mario could have a depth=-1, while the Log could have the default depth=0. |
Author: | littlelum [ Fri Jul 28, 2017 4:36 pm ] |
Post subject: | Re: Coding Help |
Thanks. I thought it was in the sprite section, not objects :) |
Author: | Spritey [ Tue Aug 08, 2017 10:07 am ] |
Post subject: | Re: Coding Help |
Wow is this all GML? I need to get back into Game Maker, I remember the code being challenging but it looks really easy now |
Author: | Auction Lemon [ Sun Aug 27, 2017 6:31 pm ] |
Post subject: | Re: Coding Help |
I know this sounds like a silly question, but does anybody know how to play as knuckles in the sonic game maker studio engine? I tried looking for a way to start testing the engine out as knuckles, but I could not find a way. Can someone please help me? Here is a link to it. https://forums.sonicretro.org/?showtopic=31723 |
Page 41 of 41 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |