Jump to content


obj_coolguy

Member Since 08 Feb 2012
Offline Last Active Mar 07 2012 06:11 AM

Topics I've Started

Shooting Straight While Drifting

03 March 2012 - 05:04 PM

Top-down space shooter. I have a ship that 'floats' in space and is able to drift and bump into other objects. However, the pilot gets dizzy when drifting and won't shoot straight.

The offending code, in obj_playership step event:
//speed and brakes
if keyboard_check(ord("W")) and speed < ship_maxsp{
    motion_add(image_angle,ship_accel);
}
    
if keyboard_check(ord("S"))and speed < ship_maxbacksp{
    motion_add(image_angle,-ship_decel);
}
    

//rotation
if keyboard_check(ord("A")){
    image_angle += ship_turnsp;
}
    
if keyboard_check(ord("D")){
    image_angle -= ship_turnsp;
}
    
    
//shooting
if keyboard_check_pressed(vk_up){
    instance_create(x,y,obj_blueblaster);
}

obj_blueblaster creation event:
image_speed = 0;

wpn_accur = obj_playership.image_angle + random_range (-4,3);

image_angle = obj_playership.image_angle;
motion_add(obj_playership.image_angle,10);

When the ship is not moving, only turning, the shooting is fine. When the ship is moving and turning and shooting the bullet shoots too far into the turn direction. My guess was to set a point in front of the ship and have the bullet head towards it, but that didn't seem to work either. Thanks in advance.

Preventing Horde Clumping

01 March 2012 - 01:28 PM

Hi. Making a top-down space shooter as my first game. There is a unit that is based on horde tactics, but they all pile on top of each other eliminating the horde effect. Basically, I want them to know to keep themselves separated from the others and push away from each other. I thought this was a simple fix with:

if distance_to_object(obj_playership) < 600
    move_towards_point(obj_playership.x,obj_playership.y,2)
    
if distance_to_object(obj_drone) < 36
    move_towards_point(obj_drone.x,obj_drone.y,-2)

But this flings them in seemingly random directions when they meet each other. I'm still pretty much a novice to coding, and haven't a clue how to fix this. Thank you in advance.

vspeed > 0

09 February 2012 - 12:11 AM

Hello? Hello! I grabbed Game Maker a few days ago and gobbled up every tutorial video and tutorial text I could find. I want to learn gml without d&d because I think it might be better for the long run. I have no prior programming experience, but I am aspiring nonetheless.


I am making a fairly simple platformer to get started. I'm having a lot of trouble using friction. Using friction introduces a variety of bugs including falling through the floor and rocketing into the ceiling if a wall is hit. I thought to use vspeed = 0 to solve most problems, but now my player won't jump. I try to make vspeed > 0 so the player can jump but gml doesn't recognize it. Help?


The offending code:

In a collision event

move_contact_solid(direction,6)
vspeed = 0


In step event

friction = 0.5;

if place_free(x,y+1){
    gravity = 1;
}   else gravity = 0;


Along with this I have basic right and left movement and jumping programmed. Everything works fine when I work without friction, but I really want the smoothiness friction provides.