Open secrui opened 4 years ago
I dont know if this is clear, i tried to be As you probably see my english is not perfect ;)
Thanks @dixtel !
Thank you :)
@unknownsteve
room.setDiscProperties(0, {x: 0, y: 0});
will change ball position to (0, 0). This way you can control all discs on the map in game. So yes, "dynamic objects" can exists :)
// example, to get current player position use room.getPlayer(player_id: int).position
const player_pos = {x: 0, y: 0};
const rectangle = {x: 0, y: 0, width: 100, height: 100};
if (player_pos.x > rectangle.x && player_pos.x < (rectangle.x + rectangle.width) && player_pos.y > rectangle.y && player_pos.y < (rectangle.y + rectangle.height) ) { // player in spot, do important things... } else { // player outside or on edge of that spot }
for circle:
// example, to get current player position use room.getPlayer(player_id: int).position const player_pos = {x: 0, y: 0}; const player_radius = 15; const circle_center = {x: 50, y: 50}; const circle_radius = 15; const deltax = player_pos.x - circle_center.x; const deltay = player_pos.y - circle_center.y;
// use pythagorean theorem to calc distance between two circles if (deltaxdeltax + deltaydeltay < (player_radius + circle_radius)*(player_radius + circle_radius)) { // player in spot, do important things... } else { // player outside that spot }
Thank you very much @dixtel :)
- Is it possible to "draw" stats on the map or the users display? For example in the bottom right of the map/the users view it shows his stats like "Your goals: 100"
You can, someone made this to display the 3 best players from the room, but you need to do every character as a "map object", which will take you a lot of time probably. And then, considering the map is just a JS Object, you can add it to your map. Oh, and since the map is the same for every player, you cannot show personalized messages like that.
- Is it possible to draw dynamic objects, like lets say, a user writes "/shoot" and it shows bullets floating away from the user?
You can not add discs in the game, but you can load a great amount of them outside the map so you can use them for this command. For this you use setDiscProperties
where you take one of your hidden discs and put them as a bullet.
- If 7. is possible, can I also stick objects to the user for example that it looks like he carries a bag?
You'd need to call setDiscProperties
every tick, but it's not supported very well. For now, I would say it's not possible.
- If I understood correctly, "every tick" works only while a game is running. Is there an option to let it run always?
setInterval with timeout of 1000/60 ~ 17
- I want to prevent shooting goals, but instead, when a goal is happening, players do not respawn but only the ball. How can I do it?
Look at kickoffReset in the map wiki, I don't have experience with it, but it might help.
Another solution is to use an alternative score, where you disable goals and you count it yourself. When a goal should be counted, you update your alternative score, and you put the ball back in the center.
This solution would work flawlessly if a method setScores
was implemented, which is not too hard to implement, except basro doesn't update the game very much.
Finally got the time to answer, so here you go.
Hello,
I have asked this on reddit too but I think I get more help here. I have seen a few videos and websites and start to understand headless host.I like the idea of creating own games.I have a few questions regarding headless host.
I'm quiet impressed by headless host and appreciate every of your answers 🥰