#Moving Boxes

1187 messages · Page 2 of 2 (latest)

barren yew
#

im just over thinking

graceful bramble
#

lol

#

so floor both x and y individually

barren yew
#

floor should be fine

graceful bramble
#

cool

#

brb then

barren yew
#

i need to go to sleep

graceful bramble
#

yeah same tbh

#

but i did the flooring on everything

barren yew
#

ok

graceful bramble
#

didnt work

#

nvm

#

gnight

barren yew
#

what didn't work?

#

wasn't to fix anything

#

it was just a pre-emptive choice

graceful bramble
#

i doesnt floor anything

barren yew
#

that's not the goal

graceful bramble
#

oh

barren yew
#

yeah that's fine

graceful bramble
#

I thought we were doing integer movment

#

nvm then

barren yew
#

yes it is

#

but its ignoring the fractions

graceful bramble
#

well

barren yew
#

but its still adding them

#

for movement precision

graceful bramble
#

it fixed the jump teleport

#

gotcha

#

aight

#

gnight

#

thanks again

#

cya tomorrow maybe

barren yew
#

next you will need to make a draw_event

graceful bramble
barren yew
#

yeah

graceful bramble
#

draw_sprite_ext(sprite_index,image_index,x,floor(y),x_facing,image_yscale,0,c_white,1)

#

thats what I have

barren yew
#

floor(x) as well now

graceful bramble
#

kk

barren yew
#

you can put that on the oBox as well

#

cause its drawing it at subpixel, its noticable

graceful bramble
#

oh?

barren yew
#

visually that is

graceful bramble
#

yeah

barren yew
#

oBox is using movement() now?

graceful bramble
#

yeha

#

ok it rounds me into the box

#

dammit

#

ill see you later dude

#

gnight

barren yew
#

alright

#

bye bye

graceful bramble
#

@barren yew, hey, mind helping once more?

#

pretty please with a cherry on top?

barren yew
#

trying to push multiple block at once?

graceful bramble
#

not just

#

the x keeps moving and isnt stuck at 0

#

if I try to push or pull a block to where it shouldnt be

barren yew
#

yeah

graceful bramble
#

I think itshere

barren yew
#

that shouldn't be

#

x is clearly changing

#

whats the problem in the video, you try to push and it fails cause there is another block

graceful bramble
#

no

#

it shouldnt push

#

but it goes into the other block by like

#

sub pixel

barren yew
#

yeah

graceful bramble
#
function Movement()
{

    
    var grounded = place_meeting(x,floor(y)+1,oCollision)
    var tolerance = 1 + ceil(abs(x_speed));
    
        if place_meeting(x+x_speed,floor(y),oCollision)
        {
            var slope = false
        
            if (grounded) 
            {
        
                for (var i = 1; i <= tolerance; i++)
                {
                    if (!place_meeting(x + x_speed, floor(y) - i, oCollision)) 
                    {
                        slope = true;
                        y -= i;
                        break;
                    }
                }
            
            }
            if !slope
            {
                if  abs(x_speed) > 1
                {
                    while !place_meeting(x+sign(x_speed),floor(y),oCollision)
                        x += sign(x_speed)
                }
                x_speed = 0
             }
        }
        else
        {
            if (grounded) 
            {
                for (var i = 0; i <= tolerance; i++) 
                {
                    if (place_meeting(x + x_speed, floor(y) + i + 1, oCollision)) 
                    {
                        y += i;
                        break;
                    }
                }
            }
        }



    x += x_speed
    

    
    if place_meeting(x,floor(y+y_speed),oCollision)
    {
        while !place_meeting(x,y+sign(y_speed),oCollision)
        {
            y += sign(y_speed)
        }
        
        y_speed = 0
    }
    
    
    y += y_speed

    
    
    

}```
#

thats Movement()

barren yew
#

you have to draw_sprite(sprite_index,0,round(x),round(y))

#

on the blocks

graceful bramble
#

lemme see

barren yew
#

perhaps draw_sprite_ext just like player draw sprite

graceful bramble
#

im flooring both x and y

#

and now it still pushing into the other box

#

but by a full pixel

barren yew
#

round the bloock

#

thing is

graceful bramble
barren yew
#

round

graceful bramble
barren yew
#

perhaps round the player too

graceful bramble
#

uhh ok

#

it like

#

staggers

#

because itsnot drawing at the subpixel

barren yew
#

ah yeah

graceful bramble
#

I could make the moving speed to 1

#

i guess

barren yew
#

they're opporating on different basis

graceful bramble
#

yeah

barren yew
#

they should both be floor, but you're moving it by 0.2 pixel, then drawing it, then setting to normal position when you stop

graceful bramble
#

yeeah

barren yew
#

also

graceful bramble
#

ok now it pushes like

#

good

#

I guess

#

no wait

#

it pushes into the wall ok

barren yew
#

i thought you changed all the place_meeting in movement()

#

to be floor as well

graceful bramble
#

but without the wall it shakes

#

I did

#

but it fucked everything up

#

one sec

barren yew
#

ko

#

ok

#

problem is your system was not built up from the ground up

graceful bramble
#

if place_meeting(floor(x)+x_speed,floor(y),oCollision)

#

like this?

barren yew
#

you need to include both

#

floor(x+x_speed)

graceful bramble
#

yeah

#
function Movement()
{

    
    var grounded = place_meeting(x,floor(y)+1,oCollision)
    var tolerance = 1 + ceil(abs(x_speed));
    
        if place_meeting(floor(x+x_speed),floor(y),oCollision)
        {
            var slope = false
        
            if (grounded) 
            {
        
                for (var i = 1; i <= tolerance; i++)
                {
                    if (!place_meeting(floor(x + x_speed), floor(y) - i, oCollision)) 
                    {
                        slope = true;
                        y -= i;
                        break;
                    }
                }
            
            }
            if !slope
            {
                if  abs(x_speed) > 1
                {
                    while !place_meeting(x+sign(x_speed),floor(y),oCollision)
                        x += sign(x_speed)
                }
                x_speed = 0
             }
        }
        else
        {
            if (grounded) 
            {
                for (var i = 0; i <= tolerance; i++) 
                {
                    if (place_meeting(floor(x + x_speed), floor(y) + i + 1, oCollision)) 
                    {
                        y += i;
                        break;
                    }
                }
            }
        }



    x += x_speed
    
    
    if place_meeting(floor(x),floor(y+y_speed),oCollision)
    {
        while !place_meeting(floor(x),y+sign(y_speed),oCollision)
        {
            y += sign(y_speed)
        }
        
        y_speed = 0
    }
    
    
    y += y_speed

    
    
    

}```
#

did I miss any?

barren yew
#

i dont understand the

#

if (place_meeting(floor(x + x_speed), floor(y) + i + 1, oCollision))
{
y += i;
break;
}

#

why is x_speed being check for y movement

graceful bramble
#

slopes

#

which btw the flooring of x broke

barren yew
#

ok

graceful bramble
#

slopes dont work now

barren yew
#

ok

#

makes no sense

graceful bramble
#

yup

barren yew
#

your first place_meeting is not floored

graceful bramble
#

thats grounded

#

why should it matter

barren yew
#

its important

#

for slopes

#

you're not gonna get the same result sometimes

#

ALL

#

your place meeting need to be on the up and up

#

this is non negotiable

graceful bramble
#

yeah

#

changed it

#

ok so I removed the round() from the draw of the player

#

not jittering any more

barren yew
#

remove or changed to floor?

graceful bramble
#

removed

#

but it also made me stick into walls

#

idk why

#

becuase its just drawing her different

barren yew
#

that's irrelevant

#

i think i know why

#

i can't help you there,

#

everything needs to be floor or round or ceiled

#

and i see lots of places everytime you post your code where its not

graceful bramble
#

im starting to not believe you

#

idk what to do

barren yew
#

telling you how it is, you can't do place_meeting with fractions

graceful bramble
#

then why not do -frac?

barren yew
#

if your character is 2, and 1 is a collision, if character move to 1.8, is that allowed?

#

that's what floor does

#

1.9 floor = 1

graceful bramble
#

frac I need to do once

#

not floor every single placemeeting

barren yew
#

1.9 - fract(1.9) is slower then just doing floor(1.9)

graceful bramble
#

slower inwhat way?

#

cpu?

barren yew
#

yeah

#

its still the same result

graceful bramble
#

does it reallymatter?

barren yew
#

it could, i dont know

graceful bramble
#

then ill do frac

barren yew
#

gonna make your code look like a mess

graceful bramble
#

I need to do it once at the end of the event

#

right before x+=x_speed

barren yew
#

on that?

graceful bramble
#

listen

#

idk whats going on anymore

barren yew
#

like i said

#

you built you system not ignoring fractions from the staart, then you asked for my help

#

and i said you can't do fractions

#

on collision check

graceful bramble
#

this never happend before

barren yew
#

cause you might still have tons of things that don't ignore fraction and some that do

graceful bramble
#

no I deleted all the rounding of x

#

everywhere

barren yew
#

so that valus don't match

graceful bramble
#

its all fractions now