Spawning the enemies
#1
Posted 05 July 2012 - 04:29 PM
Spawn1:1712x722y
Spawn2:672x1744y
Spawn3:864x384y
Also If there is a collision with a player in that position, he has to spawn the nearest positon to the spawn without colliding with the player.
Thank you for reading and helping. You'll be in Credits!
#2
Posted 06 July 2012 - 09:21 AM
Player CREATE-event:
//Set variable. Round means it rounds the number up or down, depending on the closest integer.
//NOTE: random(3) will never return 3, unless you use the "ceil" - function instead of "round".
SpawningPosition=round(random(3))
//Spawn code:
if SpawningPosition=0
{
if place_free(1712, 722) //You could also use collision_point(1712, 722, obj_player, true, true) to define a
{ //specific object to check at the coordinates, in case there are other objects.
x=1712
y=722
}
else
{
x=1712+sprite_width
y=722+sprite_width
}
}
if SpawningPosition=1
{
if place_free(672, 1744)
{
x=672
y=1744
}
else
{
x=672+sprite_width
y=1744+sprite_width
}
}
if SpawningPosition=2
{
if place_free(864, 384)
{
x=864
y=384
}
else
{
x=864+sprite_width
y=384+sprite_width
}
}
This code is pretty simple. If you run into trouble let me know
Edited by HerpDerp, 06 July 2012 - 09:42 AM.
#3
Posted 06 July 2012 - 11:18 AM
Create event:
spawn_v[0, 0] = 1712 spawn_v[0, 1] = 722 spawn_v[1, 0] = 672 spawn_v[1, 1] = 1744 spawn_v[2, 0] = 864 spawn_v[2, 1] = 384
Spawn event:
spawn = irandom(2)
var tx, ty;
tx = spawn_v[spawn, 0]
ty = spawn_v[spawn, 1]
while (place_meeting(tx, ty, obj_player))
{
tx += lengthdir_x(10, random(360))
ty += lengthdir_y(10, random(360))
}
x = tx
y = ty
Edited by filulilus, 06 July 2012 - 11:19 AM.
#4
Posted 06 July 2012 - 01:29 PM
Can you help me with this?
How can i make an object stay at same view position??
Edited by codmaker, 06 July 2012 - 01:32 PM.
#5
Posted 06 July 2012 - 01:45 PM
You mean you like the view to follow an object?How can i make an object stay at same view position??
You can simply set that in the room editor at the view tab!
...or use this code...
view_xview[0] = obj_player.x - view_wview[0] / 2 view_yview[0] = obj_player.y - view_hview[0] / 2
or did you mean an object to follow the view, like an UI?
x = view_xview[0] y = view_yview[0] draw_text(x + 10, y + 10, 'AMAGAD! TEXT IN THE VIEW CORNER!'
Edited by filulilus, 06 July 2012 - 01:46 PM.
#6
Posted 06 July 2012 - 01:52 PM
Thank you for trying to help,my english is not the best
Edited by codmaker, 06 July 2012 - 01:53 PM.
#7
Posted 06 July 2012 - 01:53 PM
You mean you like the view to follow an object?
How can i make an object stay at same view position??
You can simply set that in the room editor at the view tab!![]()
...or use this code...view_xview[0] = obj_player.x - view_wview[0] / 2 view_yview[0] = obj_player.y - view_hview[0] / 2
or did you mean an object to follow the view, like an UI?x = view_xview[0] y = view_yview[0] draw_text(x + 10, y + 10, 'AMAGAD! TEXT IN THE VIEW CORNER!'
^ Lolled there.
#8
Posted 06 July 2012 - 01:59 PM
Thank you, but what I am asking is: I have an object that has apeared in a random position of the room, but now we can see it in the view(obiously if the camera moves the object will get out of the view) i want to get his create xview and yview and make it persistent in the points of the view
I'm sorry but I don't understand the question, the only thing I can think of (other then what I've already posted) is that the player will be spawning inside the view?
#9
Posted 06 July 2012 - 02:13 PM
I want the object to stay in those view coordinates, even my player moves(my camera follows this object)
#10
Posted 06 July 2012 - 02:19 PM
You like an object to stay inside the view like he is a member of the players team?
The view varaibles like "view_xview[0]" are global variables which mean they can be accesed by any object!
if x < view_xview[0]
{
//no no no, go back they way you came from!
x += 10
//or
hspeed = -hspeed
//or some other turn code...
}
if x > view_xview[0] + view_hview[0]
{
//no no no, go back they way you came from!
x -= 10
//or
hspeed = -hspeed
//or some other turn code...
}
#11
Posted 06 July 2012 - 02:23 PM
Edited by HerpDerp, 06 July 2012 - 02:45 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











