Go to page Previous  1 ... 37, 38, 39, 40, 41  [ 804 posts ]  Reply to topicPost new topic 
Coding Help, Questions and Issues relating to coding
Author Message
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Feb 15, 2017 6:53 pm 
User avatar
Member
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

 
Top
Offline 
 User page at mfgg.net
 
 [es]
 Post subject: Re: Coding Help
PostPosted: Tue Mar 28, 2017 12:49 am 
User avatar
I'm just a little adorable kitty :3
Member
[*]
[*]
[*]
[*]
[*]

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

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.

_________________
Image ImageImageImageImageImageImage Image
~ Supernova / Drawerkirby (2) / Gato / Neweegee (2) ~
"shy guys are wall plugs confirmed" - Vitiman on Club Saturn Ex
Image
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: Coding Help
PostPosted: Tue Mar 28, 2017 6:21 am 
User avatar
Member
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);

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 19, 2017 7:15 am 
User avatar
Gameboy Style!
Member
[*]
[*]
[*]
[*]
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...

_________________
Image

Image
NNID: SonicZetrex
User: SonicZetrx


Old Drawing Banners

Spoiler:

Things I support/others

Spoiler:


My favorite theme:

 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
Go to page Previous  1 ... 37, 38, 39, 40, 41  [ 804 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:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group