Jump to content


Marchal_Mig12

Member Since 01 Apr 2005
Offline Last Active Apr 27 2013 07:11 PM

Posts I've Made

In Topic: another collision problem.

05 July 2012 - 04:15 PM

Then I would set a timer based on the length and speed of the laser to each array after which the laser would be able to hit the target again.

In Topic: another collision problem.

05 July 2012 - 02:26 AM

mrokke96, that will not solve the problem. At all. It doesn't even address the issue.

matthewberry23, I suggest you create a variable in the enemy's create event (let's call it hit) and set it to 0. When the enemy is hit by the laser, set it to 1. If it is no longer hit by the laser, set it to 0 again. Then, make the damage code only execute if hit equals 0. You will need to modify the code to be executed from the step event, though, since there is no other way to check whether a collision is NOT occurring. Let me do that for you...

if (!hit) {
    if (place_meeting(x, y, lazer)) {
        hit = 1;
        hp -= global.str / def + physical_weak;
        }
    }
else {
    if (!place_meeting(x, y, lazer)) hit = 0;
    }
Note that shooting two or more lasers at the enemy while the first laser is still colliding with it will only hurt the enemy once - if you need the lasers to remember which enemies they've hit already, you will need a more complicated solution involving a ds_list. If the code above isn't sufficient for your needs, let us know.



The problem with that is that if two lasers hit an enemy at the same time, only one of them will deal damage. Depending on your game mechanics, I would recommend doing the above suggestion using an array. So for example you would store in each enemies, which lasers have hit them. Then, each time a laser hits an enemy, you check through that array if the laser has already hit or not.

In Topic: Equal Movement

29 June 2012 - 07:56 PM


What part of it you don't understand?

When I plug the code into the step event of my character he keeps moving right for some reason...


Well you could add a little something like this :

var mySpd,hspd,vspd,spdDir;
mySpd = 4; //Character speed
hspd = 0;
vspd = 0;
if keyboard_check(ord("W")) then {vspd-=4}
if keyboard_check(ord("S")) then {vspd+=4}
if keyboard_check(ord("A")) then {hspd-=4}
if keyboard_check(ord("D")) then {hspd+=4}
if hspd <> 0 && vspd <> 0 {
spdDir = point_direction(0,0,hspd,vspd);
x += lengthdir_x(mySpd,spdDir);
y += lenghtdir_y(mySpd,spdDir);
}

In Topic: Equal Movement

29 June 2012 - 05:10 PM

What part of it you don't understand?

In Topic: Collision Event

29 June 2012 - 04:39 PM



I have a lot of collision events with my character and different objects I DO NOT want him to be able to go through. I want to know if there is a way to take these events and make them into coding so that the don't clog up my other events.


The best way is using functions in step event instead.

fonctions such as :

collision_circle
collision_rectangle
instance_place
place_meeting

I tried this code, but it doesn't seem to be working. The car and the character are both solid, but the character still goes right through the car.

In the characters step event:
if(place_meeting(x,y,obj_car))
{move_contact_solid(0,1)}


In order to use that, the object for the car should be solid. Also when you use move_contact_solid, you should also use the direction of the player with it.