Unaligned
Unaligned
Posts

7

Following

9

Followers

16

This user leads a boring life.

Joined on January 4, 2008, 1:47 AM Visited on April 24, 2019, 9:11 PM
Badges

project:embraced 0.03

by Unaligned


Posted on April 16, 2017 at 4:55 PM


real name for a future update
how to play and stuff

Oh god collisions So after realizing I couldn't make jump-through blocks and reading this I decided to re-write the collisions in the game by getting rid of solid block-like objects and any use of move_contact_solid.

exhibit A of collision implementation woes

Now instead of the very occasional bug where the player is stuck in a corner because of the collision box doing weird stuff I get an occasional hang that I can't replicate. It seemed to happen when a lot of bullets hit someone at the same time, but then I discovered it could also happen at random, for no apparent reason.

not even late-night eureka moments I leave for the next day for myself can save me

Anyway, if you want to take a crack at this, here's how it currently works:
collision code (Show)

Warning: sub-par code ahead

tl;dr: if the amount of distance covered due to force until the next frame exceeds the distance to the obstacle, negate the application of force and just place the entity next to the obstacle

this goes in the step event
//Horizontal Collision
var hcollide;
hcollide = instance_place(x+hspeed,y,obj_block);
if (hcollide != noone)
    {
        //only with normal blocks
        if ((hcollide).type == 0)
            {
                if (place_meeting(x+hspeed,y,obj_block))
                    {
                        x = round(x-hspeed)
                        while (!place_meeting(x+sign(hspeed),y,obj_block) && hspeed!=0)
                            {
                                x+=sign(hspeed)
                            }
                        hspeed = 0
                    }
            }
    }
//Vertical Collision
var vcollide;
vcollide = instance_place(x,y+vspeed,obj_block);
if (vcollide != noone)
    {
        //normal blocks
        if ((vcollide).type == 0)
            {   
                y = round(y-vspeed)
                while (!place_meeting(x,y+sign(vspeed),obj_block) && vspeed!=0)
                    {
                        y+=sign(vspeed)
                    }
                vspeed=0
            }
        //jump-through blocks
        if ((vcollide).type == 1 && vspeed > 0)
            {
                if (!place_meeting(x,y,obj_block))
                    {
                        while (!place_meeting(x,y+sign(vspeed),obj_block) && vspeed!=0)
                            {
                                y+=1
                            }
                        vspeed=0
                    }   
            }
    }

this one is used for just about any application of force (knockback when shooting, impact from bullet, air double jump/boost, etc.)...and while writing this I realized I haven't extended it to player inputs like walking or jumping...
///add_force(direction, speed)
//essentially motion_add, but prevents lodging entities into blocks
//declare shit
var dir, spd, vspd, hspd, blk
dir = argument0
spd = argument1
//break down into hspeed & vspeed
dir = degtorad(dir)
hspd = spd * cos(dir)
vspd = - spd * sin(dir)
//apply speeds if there's nothing to stop us
blk = instance_place(x+hspeed+hspd,y,obj_block)
if (!place_meeting(x+hspeed+hspd,y,obj_block))
    {
        hspeed = hspeed + hspd
    }
else if (blk!=noone)
    {
        if (blk.type!=0) {hspeed = hspeed + hspd}
        else
            {
                while (!place_meeting(x+sign(hspeed+hspd),y,obj_block) && hspd!=0) {x+=sign(hspeed+hspd)}
            }
    }
    
blk = instance_place(x,y+vspeed+vspd,obj_block)
if (!place_meeting(x,y+vspeed+vspd,obj_block))
    {
        vspeed = vspeed + vspd
    }
else if (blk!=noone)
    {
        if (blk.type!=0 && vspd<0) {vspeed = vspeed + vspd}
        else
            {
                while (!place_meeting(x,y+sign(vspeed+vspd),obj_block) && vspd!=0) {y+=sign(vspeed+vspd)}
            }
    }

What about that draw_line_width_color? How is this function such a resource hog? I couldn't help but play around with weapon variables and essentially flood the map with bullets. My FPS tanked hard until I reduced the length of bullet trails (that use said function).

So what's new? pussycat --The big--
No more aggressive wrist-flicking, player character moves whole arm when aiming up/down.
Gravity wells and... anti-wells I guess, check them out at dm_wells (& dm_test).
Jump-through blocks (cyan, translucent, for now). Jump downwards by aiming down and pressing jump when standing on one.
Completely re-worked the collision system, allowing for different kinds of blocks and introducing all sorts of new bugs!
Made bullets: have way better hitboxes (adjusted to size and angle), do more damage, appear bigger on screen, move faster (more knockback and less player momentum transferral as an indirect consequence, we'll see about that)
New weapon: the totally original, pink-bulleted, enemy-chasing needl-chaser!

--The small--
Explosions now not-to-intensely flash the screen - too much/little?
Weapon pickups now hover because it looks cool
"Blood" effect is now darker, so it's less distracting.
Players now have a small label on top indicating what player number they are, will allow setting custom player names/profiles in the future
Map edges draw an arrow if a player is out of the level
Default armor is 100 again, with more damaging bullets and all
Armor recharges at a higher rate
Bullet lighting is now oval-shaped, and brighter
Made quick edits on gun sprites so they're slightly more identifiable
Improved respawn choice algorithm to reduce chance of overlap, not perfect yet though
Camera only tracks dead players for a short time after dying

Download links pls Take your pick: