• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Screen Wrapping for top down

J

Johnathan

Guest
This is a topic I can not find a single clue on. It's a top down shooter based on moon like planet

Let me start off by describing exactly what I'm looking for.
Lets say you start at the north pole i'd like to be able to move all around the planet.
Enemies chasing player even as "wrapping"

a.png

dimensions are:
Room size:
1536
2688

View in room
x 0
y 0
w 768
h 1024

port on screen
x 0
y 0
w 768
h 1024

following object player (centered)



I am using:
if (x > (room_width-(view_wview[0] / 2))+1){
x = (view_wview[0] / 2)+1;
view_xview[0] = 0;
}
if (x < (view_wview[0] / 2)){
x = (room_width-(view_wview[0] / 2));
view_xview[0] = (room_width-view_wview[0]);
}
method of looping horizontal just as a test.

I have come to a couple problems:
1 its just teleport me to the other side of the room
This makes enemies that are chasing me stop chasing me and start coming at me from the other way and vanish from view.
also, anything that is in sight just disappear from my view completely until I reach that side again..

Perhaps I am looking more to move the environment as a way to make this more possible. But I am unsure on how to do this. because so far when I tried all I was able to do was make it look like I was moving but the speed of the enemies were exactly the same as when I wasn't moving at all. so If I am running away from them shouldn't they be slower than running towards them? anyway I would Highly appreciate any help on this! this is the last big thing I have left to do!
 
J

Johnathan

Guest
no not exactly. kind of like 360 motion. I have been messing around with moving the background and enemies instead of the actual player.

Here is my code with that. I reall like how this looks I just cant seem to get the enemies to calculate their speed with the vertical and horizontal difference.

This is for the player

image_angle=point_direction(x,y,object_target.x,object_target.y) //Points image towards the mouse location/target

global.xSpeed = lengthdir_x(global.maximus_speed,object_maximus.image_angle); //sets the xspeed based on the player speed/angle
global.ySpeed = lengthdir_y(global.maximus_speed,object_maximus.image_angle); //sets the yspeed based on the player speed/angle

background_hspeed[0] = -global.xSpeed; //makes the background move opposite of the player horizontal
background_vspeed[0] = -global.ySpeed; //makes the background move opposite of the player vertical

(This looks really good. The player "seems" to be walking around flawlessly and infinitely)

This I for the ENEMY

move_towards_point(object_maximus.x, object_maximus.y, spd)

Now the enemies are still moving towards the player. But they are still moving as though he is still standing still.
When I put the -global.xSpeed and -global.ySpeed it seems that the values are coming out wrong. I can not figure out how to add or subtract the global.x Speed and global.ySpeed variables into the enemy movment.



Basically if I am "running away" they should be slower but if I am "running towards" they should be faster.
 
J

Johnathan

Guest
hspeed = -global.xSpeed;
vspeed = -global.ySpeed;

makes them look like they are standing in 1 place so I know this is right. I just need to add in the movement towards the player with that.
 
J

Johnathan

Guest
my player does not move technically. instead the background moves. so I need some help getting the enemies to move towards the player while taking in consideration if the player is "moving"

as of now if I point left the are really fast but if I point right they actually go away from the player because the speed is registering as negative number.
 
Top