Jump to content


Orion987

Member Since 21 Oct 2009
Offline Last Active Aug 05 2011 02:51 AM

Topics I've Started

Out of Collision Ideas

04 August 2011 - 12:32 AM

Hello. I am running into an issue in my top down shooter. I have a large number of enemies that at times walk randomly around, or other times try moving within a small area (yes it's a zombie game, I'm sorry, don't judge me  :D ). I need them to sort of "slide" off each other, or avoid each other along the way. When I say a large number, I mean there is at many times a unit right in front of it, behind it, and to the sides of it. I recognize that making the collisions look and function well would be very difficult, but I am just more worried about them not getting stuck on each other nonstop.

The units themselves technically don't need pathfinding, they are only told to move to places they can see. However, sometimes they still bump into a wall along the way, and they certainly run into large amounts of themselves. What would be the best way to tell them to avoid (or just slide off of) a wall object AND an enemy object (I can not use a parent object because they already have different ones for the lighting engine I am using) while they are moving to a point? Their mask is already a perfect circle.

I apologize ahead of time for asking a question that I imagine gets answered a lot. I have looked into this for a long while now, however, and have not found anything that successfully does this. I also apologize if this really is not possible. I know my situation (considering the amount of enemies, and since I need to avoid two objects without using parents) is not ideal. Please tell me if I have left out any important information. Thanks!

Edit: Forgot to mention, no objects in the game are 'solid'

Help with Sprite Animation and image_speed

22 June 2011 - 10:28 PM

Hello. I have a overhead view game. The units in my game have walking animations, which are cycled by image_speed. I have set the image_speed to 1/5, so from my understanding, it should switch to the next image_index every 5 frames. However, it is unbalanced, when I watch frame by frame I can see it doing it sometimes on 4,5, or 6. I assume it is because I have this code set up in my draw event...

if image_angle > 225 and image_angle < 315 {
        image_speed = 1/5 
            if image_index>3
            {image_index=0}
}
if (image_angle >= 135 and image_angle <= 225) {
        image_speed = 1/5
            if image_index>7 or image_index<4
            {image_index=4}
}
if (image_angle >= 0 and image_angle <= 45) {
        image_speed = 1/5
            if image_index>11 or image_index<8
            {image_index=8}
}
if (image_angle >=315) {
        image_speed = 1/5
            if image_index>11 or image_index<8
            {image_index=8}
}
if (image_angle > 45 and image_angle < 135) {
        image_speed = 1/5
            if image_index>15 or image_index<12
            {image_index=12}
}


This is there because my up, down, left, and right sprites are not in different indexes, but are instead in order (0,1,2, and 3 are the down sprites, etc.). I would prefer to keep it this way due to the large number of different possible sprites in my game. It would be very inconvenient to have 4 indexes for each sprite.

I am assuming that image_speed is changing the animation at the right time, but then whenever the draw event goes off and the image_index is outside where it should be, it puts it down 4 spots and thus makes it look funny.

I guess my two questions are...

1) When does the draw event 'run' in a step. I clearly have no idea as to what order or how any of the different step, draw, or other events are run.

2) Does anyone have any ideas how to make my sprites cycle every 5 steps while still using this code (obviously modified, I just dont wan't to change everything to 4 sprite indexes)?

Thanks! Please tell me if I left out any important information or was not clear on something.

Drawing Text in Multiple Views?

09 June 2011 - 09:00 PM

Hello. I apologize if this has been answered before, but I couldn't find any posts with a scenario like mine. Anyway...

I have a game that is shown through view 0. There is a zoom function on the game that changes the size of view 0. Once the game is zoomed in, you can scroll by moving the mouse around the edge of the screen. However, I would like to have a static UI with static text across the bottom (it doesn't NEED to be clickable). I am unsure how to go about this. I know how to make this work when it is zoomed out OR in, but I can't get one to keep consistent size after zooming in or out. I read that there might be a way to have another view going that doesn't get changed, but I am unsure how to do this (I know how to enable and set up the size and viewport of another view, I just don't know how to draw my text on that view then...)

I apologize if I am being unclear about something. Please tell me if there is any relevant information that I forgot to post. Thanks!

Help with my MP Grid

19 April 2011 - 02:00 AM

Hello. I am using an mpgrid for my units pathfinding. Specifically...

global.mpGrid = mp_grid_create(0,0,room_width/32,room_height/32,32,32);
mp_grid_add_instances(global.mpGrid,solids,0);

Btw, 'solids' is supposed to have an s on the end. It's a parent object for objects I think of as solid without the actual solid properties. Anyway...

My units are using this mpgrid to move around with this script in the step event... (it's a script I took from an example Fede-lasse made)



var _minimumDistance;
_minimumDistance = (1+argument3)*(1+friction);

if (point_distance(x,y,argument1,argument2) <= argument3) {
x = argument1;
y = argument2;
return (0);
}

if (collision_line(x,y,argument1,argument2,argument4,1,1) == noone) {
motion_add(point_direction(x,y,argument1,argument2),argument3);
if (path_get_number(__mpPath) > 0) {
path_clear_points(__mpPath);
}
__mpPosition = 1;
} else {
var _pathNumber;
_pathNumber = path_get_number(__mpPath);
if (distance_to_point(path_get_point_x(__mpPath,__mpPosition),path_get_point_y(__mpPath,__mpPosition)) <= _minimumDistance ||_pathNumber <= 0) {
if (!mp_grid_path(argument0,__mpPath,x,y,argument1,argument2,1)) {
return (-1);
}
__mpPosition = round(_minimumDistance)+1;
path_set_kind(__mpPath,1);
path_set_precision(__mpPath,1);
} else {
motion_add(point_direction(x,y,path_get_point_x(__mpPath,__mpPosition),path_get_point_y(__mpPath,__mpPosition)),argument3);
}
}





I like the smooth movement it makes but unfortunately my map is not made of nice blocks like the previous game I used this script with. The solids in this map are round and sometimes go right next to the grid's lines, and the units frequently get stuck on close corners. I don't want to turn the cells on the grid up any larger because they need to go through certain smaller areas. I drew the mpgrid and the path in game and the path seems to look fine. It's just that the unit doesn't follow it perfectly and cuts corners slightly. Is there anyway to get him stick closer to the path without completely tossing this script?

Thanks! Sorry this was such a long post.

Edit: Oh, btw, the sprite is not too large for the grid to work, that is not the problem. The problem is that he tries to cut corners (even when diagonal is turned off the path created still has diagonals, I think it has something to do with the script I borrowed).

Help with Random Variables and Game Seed

01 March 2011 - 10:38 PM

I am working on a game that uses many variables that are randomly generated to affect the gameplay. However, I would like it so that if my friend is next to me on a different computer, we could both input a game seed and get the same levels/variables. I have read that random_set_seed() sets the seed (duh). I have also read that if I set the seed first, all random numbers generated after that will be generated the same each time I use that seed. However, some people have said that it is also dependant on your system (I don't know the technical stuff). What I'm asking is...

If I set the game seed to the same value on both computers, will each computer output the same numbers in the same circumstances if I use random(), regardless of what computer it is played on? If not, is there anyway I can get them to do that? Lastly, is there anyway to check the game seed in game? Thank you ahead of time! Sorry if I did not explain this well enough. If I left out any information please ask.