Skip to main content

News

Topic: Gauntlet clone, with extra features, and also online. (Read 14088 times) previous topic - next topic

  • Mooch
  • [*]
  • Verified
Gauntlet clone, with extra features, and also online.
Using Sphere 1.5 [recommended] on Windows XP Professional

To get myself back into the swing of programming after awhile, I'm gonna try to make a simple Gauntlet-style game. It'll be a straightup clone at first, but then I'm gonna see if I can make it unique.

Due to medical problems that make it difficult for me to use a computer for long periods of time, and doubly due to my inexpertise in programming in the first place, this is gonna be a long, slow project. I'm mainly making this topic to motivate myself to think things through and stick with it.

Anyway, I'm going to implement one tiny feature at a time. It's probably best for me if I only describe what I'm working on at the moment; if I start listing all the features I wanna include, I'll just get too carried away, too daunted and give up.

So! First, simple thing's first. Laughably simple, since Sphere has the MapEngine -- just get four players moving around the screen at the same time. No online yet, I'll just have them all controlled from the same keyboard. I'll post again when I finish, or hit a roadblock.

EDIT: Okay, roadblock one. Well, question, actually. When importing a tileset, is it possible to have it offset the tiles? 'cause I found a nice Guantlet II tileset, but there's borders between the tiles, and I'd like to not have to edit the file myself to get rid of them.

Also, can I choose an "invisible color" for tiles? I know you can for sprites, but what about tiles?

Also also, can a map have a background color? So that I could have it show through the invisible parts of the tiles, of course.

'Nother Problem: Trying to create a spritesheet.

1) How do I change the dimensions of sprites? It's 16x32, I want it 16x16.

2) When I edit or paste an image into one frame of one direction, it edits or pastes it into all the frames for every direction!
  • Last Edit: December 01, 2013, 12:15:03 am by Mooch

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Gauntlet clone, with extra features, and also online.
Reply #1

EDIT: Okay, roadblock one. Well, question, actually. When importing a tileset, is it possible to have it offset the tiles? 'cause I found a nice Guantlet II tileset, but there's borders between the tiles, and I'd like to not have to edit the file myself to get rid of them.


No, you'll have to do that manually or write some code to do that for you. :/


Also, can I choose an "invisible color" for tiles? I know you can for sprites, but what about tiles?


Yes, there is an alpha slider in the tile image editor, slide it to 0 and floodfill the area. It's no different than what you do for all other images in Sphere whether you are using my editor or the vanilla editor.


Also also, can a map have a background color? So that I could have it show through the invisible parts of the tiles, of course.


Well yeah, you create a tile of a certain color and then flood fill that on a bottom-most layer.


1) How do I change the dimensions of sprites? It's 16x32, I want it 16x16.


Go to the menu. Hit spriteset. Then hit resize. Type in your size and go.


2) When I edit or paste an image into one frame of one direction, it edits or pastes it into all the frames for every direction!


Well there are two views in the spriteset editor, which I guess makes it a bit confusing to first use. There is the direction view and the tileset view. You want to do the manipulations in the tileset view and then change the frames in the direction view. The reason why you see the frames automatically update is because they are all tied to the same graphic in the tileset. Once you realize the tileset graphic and the direction frames are linked then you just create new images for the new frames and go on from there.

Edit:
I should say your goal is MASSIVE. To get 4 players walking, tied to different inputs is not easy. Sphere makes the key mapping easy by having a player configuration hidden under the hood, but the movement input is set up to a single entity only. To manipulate four different people requires mastery over Sphere's command queue. It's not overly difficult, it is possible, but it's not a standard built-in component of the map engine.

I'd try to get a single person walking around. Teleporting. Leveling. Killing monsters. Loot. Then worry about adding three others afterwards, and internet stuff last.
  • Last Edit: December 01, 2013, 02:41:01 am by Radnen
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Mooch
  • [*]
  • Verified
Re: Gauntlet clone, with extra features, and also online.
Reply #2


EDIT: Okay, roadblock one. Well, question, actually. When importing a tileset, is it possible to have it offset the tiles? 'cause I found a nice Guantlet II tileset, but there's borders between the tiles, and I'd like to not have to edit the file myself to get rid of them.


No, you'll have to do that manually or write some code to do that for you. :/


Oh well. GameMaker has it, I got used to it, heh. I'll just edit the png.



Also, can I choose an "invisible color" for tiles? I know you can for sprites, but what about tiles?


Yes, there is an alpha slider in the tile image editor, slide it to 0 and floodfill the area. It's no different than what you do for all other images in Sphere whether you are using my editor or the vanilla editor.


Ah, there it is. Thanks. I'm using the vanilla editor because "Sphere Editor.exe is not a valid Win32 application." I can't get your editor to work. Probably should've made a topic about that, I assume your editor has a bazillion features the normal one doesn't.



Also also, can a map have a background color? So that I could have it show through the invisible parts of the tiles, of course.


Well yeah, you create a tile of a certain color and then flood fill that on a bottom-most layer.


I was not aware there were multiple tile layers. The 1.5 editor isn't very newbie-friendly, apparently. Or I'm especially dumb, which is not at all unlikely.


1) How do I change the dimensions of sprites? It's 16x32, I want it 16x16.


Go to the menu. Hit spriteset. Then hit resize. Type in your size and go.


Ah! Didn't see that pop up on the menu.



2) When I edit or paste an image into one frame of one direction, it edits or pastes it into all the frames for every direction!


Well there are two views in the spriteset editor, which I guess makes it a bit confusing to first use. There is the direction view and the tileset view. You want to do the manipulations in the tileset view and then change the frames in the direction view. The reason why you see the frames automatically update is because they are all tied to the same graphic in the tileset. Once you realize the tileset graphic and the direction frames are linked then you just create new images for the new frames and go on from there.


Oh! I see. Man, that is NOT made clear anywhere. I know -- I'm gonna make a newbie-friendly tutorial and slap it up on the Wiki as I go along and learn things. That way, nobody else will have to scratch their heads at this stuff, we can just point 'em to my tut.

Edit:
I should say your goal is MASSIVE. To get 4 players walking, tied to different inputs is not easy. Sphere makes the key mapping easy by having a player configuration hidden under the hood, but the movement input is set up to a single entity only. To manipulate four different people requires mastery over Sphere's command queue. It's not overly difficult, it is possible, but it's not a standard built-in component of the map engine.


Aw, whaaat? I thought AttachInput would be, how to say, instanced. Like, if I have four people all playing together online, AttachInput would only control their character.

I guess that explains why, despite the socket stuff in the API, nobody's doing anything with online multiplayer -- Sphere is built to be single-player.

Well, fudge-sicles. There's no way I'm gonna be able to do something as complex as multiplayer input on my own. I guess I'll abandon the Gauntlet clone, then, and think of something singleplayer to work on.

I don't suppose it'd be a simple matter for you to, on the next Sphere release, add AttachInput1, AttachInput2, etc. commands to the API, huh?

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Gauntlet clone, with extra features, and also online.
Reply #3
Um. I don't see why you wouldn't be able to control four characters at the same time from a single keyboard. Yes, they all come from the same single command queue, but you're pressing different keys for different characters so it's not really an issue. Heck, even several keyboards would work, as long as you set up different keys for different players. Adding controller support for this would also not be difficult.

The main hurdle with having four people on the same keyboard, though, is that most keyboard seem to have a hardware limitation where you can only press 4 to 5 keys at the same time. If you press more keys than that, they're just not sent to the system at all (so this is a problem for any software, any OS, etc). Having multiple keyboards or gamepads could solve this, easy.





2) When I edit or paste an image into one frame of one direction, it edits or pastes it into all the frames for every direction!


Well there are two views in the spriteset editor, which I guess makes it a bit confusing to first use. There is the direction view and the tileset view. You want to do the manipulations in the tileset view and then change the frames in the direction view. The reason why you see the frames automatically update is because they are all tied to the same graphic in the tileset. Once you realize the tileset graphic and the direction frames are linked then you just create new images for the new frames and go on from there.


Oh! I see. Man, that is NOT made clear anywhere. I know -- I'm gonna make a newbie-friendly tutorial and slap it up on the Wiki as I go along and learn things. That way, nobody else will have to scratch their heads at this stuff, we can just point 'em to my tut.

If it helps, I made a (bit too fast) video tutorial on basic usage of the sprite editor. It explains exactly this. http://youtu.be/3jt8r-KKPkU
Edit: wow, looking back at it, I really need to remake this video tutorial. My previous recording software bugged out, making things too fast and messy.


I also have to say... You've been trying out some not quite conventional stuff that makes me realize that Sphere really needs some new and changed functionality... Hopefully, when TurboSphere and Sphere-SFML are complete, issues like these will be addressed and functionality will be added. Sorry to read that the engine isn't quite convenient for some of your purposes right now, though. :)
  • Last Edit: December 01, 2013, 10:28:03 am by DaVince

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Gauntlet clone, with extra features, and also online.
Reply #4

Um. I don't see why you wouldn't be able to control four characters at the same time from a single keyboard. Yes, they all come from the same single command queue, but you're pressing different keys for different characters so it's not really an issue. Heck, even several keyboards would work, as long as you set up different keys for different players. Adding controller support for this would also not be difficult.

The main hurdle with having four people on the same keyboard, though, is that most keyboard seem to have a hardware limitation where you can only press 4 to 5 keys at the same time. If you press more keys than that, they're just not sent to the system at all (so this is a problem for any software, any OS, etc). Having multiple keyboards or gamepads could solve this, easy.


For those who are experienced it's not too bad, but I don't know if a newbie can so easily do it. It's not an out-of-the-box thing for Sphere, like single player movement is.

Hmm, a good start I guess:
Code: (javascript) [Select]

function Move(name, inputs) {
    if (!IsCommandQueueEmpty(name)) return;

    if (IsKeyPressed(inputs.up)) QueuePersonCommand(name, COMMAND_MOVE_NORTH, false);
    else if (IsKeyPressed(inputs.down)) QueuePersonCommand(name, COMMAND_MOVE_SOUTH, false);
    else if (IsKeyPressed(inputs.left)) QueuePersonCommand(name, COMMAND_MOVE_WEST, false);
    else if (IsKeyPressed(inputs.right)) QueuePersonCommand(name, COMMAND_MOVE_EAST, false);
}

var inputs = [];
inputs[0] = { up: KEY_UP, down: KEY_DOWN, left: KEY_LEFT, right: KEY_RIGHT };
inputs[1] = { up: KEY_W, down: KEY_S, left: KEY_A, right: KEY_D };
inputs[2] = { up: KEY_U, down: KEY_J, left: KEY_H, right: KEY_K };
inputs[3] = { up: KEY_NUM_8, down: KEY_NUM_2, left: KEY_NUM_4, right: KEY_NUM_6 };

var players = ["player1", "player2", "player3", "player4"];

function Update() {
    for (var i = 0; i < players.length; ++i) {
        Move(players[i], inputs[i]);
    }
}

function game() {
    CreatePerson("player1", "player.rss", false);
    CreatePerson("player2", "player.rss", false);
    CreatePerson("player3", "player.rss", false);
    CreatePerson("player4", "player.rss", false);

    SetUpdateScript("Update()");
    MapEngine("map.rmp", 60);
}


I guess that's the minimum. You'll have to set the people in different places, otherwise they'll be on top of each other. Notice I didn't use AttachInput(), that means triggers won't fire, and NPC's can't be talked to. But there are ways around that. The above is a good start tho.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Mooch
  • [*]
  • Verified
Re: Gauntlet clone, with extra features, and also online.
Reply #5

Um. I don't see why you wouldn't be able to control four characters at the same time from a single keyboard. Yes, they all come from the same single command queue, but you're pressing different keys for different characters so it's not really an issue. Heck, even several keyboards would work, as long as you set up different keys for different players. Adding controller support for this would also not be difficult.


That was actually my plan; I was gonna design this for use with game controllers. I was gonna have the 1, 2, 3, 4, 5, 6, 7 and 8 keyboard keys be used as Up, Down, Left, Right, B, A, Select, Start for Player 1, and q through i for Player 2, and a through k for Player 3, and z through , for Player 4.

Linerally like that so you can easily hook the corresponding commands up to the different game controllers you have plugged in.

The main hurdle with having four people on the same keyboard, though, is that most keyboard seem to have a hardware limitation where you can only press 4 to 5 keys at the same time. If you press more keys than that, they're just not sent to the system at all (so this is a problem for any software, any OS, etc). Having multiple keyboards or gamepads could solve this, easy.


No need -- just use a keyboard emulation program like GlovePIE. Indeed, I wanted to specifically design this for use with GlovePIE and Wiimotes. It's a fantastic program, you should take a look at it.





2) When I edit or paste an image into one frame of one direction, it edits or pastes it into all the frames for every direction!


Well there are two views in the spriteset editor, which I guess makes it a bit confusing to first use. There is the direction view and the tileset view. You want to do the manipulations in the tileset view and then change the frames in the direction view. The reason why you see the frames automatically update is because they are all tied to the same graphic in the tileset. Once you realize the tileset graphic and the direction frames are linked then you just create new images for the new frames and go on from there.


Oh! I see. Man, that is NOT made clear anywhere. I know -- I'm gonna make a newbie-friendly tutorial and slap it up on the Wiki as I go along and learn things. That way, nobody else will have to scratch their heads at this stuff, we can just point 'em to my tut.

If it helps, I made a (bit too fast) video tutorial on basic usage of the sprite editor. It explains exactly this. http://youtu.be/3jt8r-KKPkU
Edit: wow, looking back at it, I really need to remake this video tutorial. My previous recording software bugged out, making things too fast and messy.


Heh, nice. I thought of using "directions" as animations, too ^_^ Actually, I thought of having 16 x 16 sprites, but actually making them 16 x 32, but only drawing the sprite as 16 x 16 pixels on the lower half of the sprite area, and having the hitbox only be in that area, and using the top half for expression bubbles, like question marks and exclamation points.

I think the main point of confusion is that it's simply not clear at all that the sprite window at the right is part of the process of making a Spriteset.

Either way, I'm gonna get to work on my tutorial.

I also have to say... You've been trying out some not quite conventional stuff that makes me realize that Sphere really needs some new and changed functionality... Hopefully, when TurboSphere and Sphere-SFML are complete, issues like these will be addressed and functionality will be added.


I always push the bounds of any system I use ^_^

I originally got into game programming with Graal Online back in the early 2000s, before they went pay-to-play. That had a C-like scripting system that was so awesome and good, it spoiled me. It had ultra-useful commands like PlayerTouchesMe[Direction], TouchedBy[Entity]. I had to do so little work myself, and got such great results out of it.

Then I got into RPG Maker 2000 and quickly outstretched the limitations of that. Again, so much work was done for me, though, that I got lazy. I got into Game Maker later, but didn't like its closed source.

Actually, funny story, I came across Sphere by complete, utter accident. There's this guy called Musashi who has a website of tabletop RPG and MMORPG-related rants (originally started back in 1995, so it's mostly talking about the original Everquest @_@) and in one article, he mentioned "writing a Sphere shard."

It turns out he was talking about something completely different, some sort of Everquest custom game hosting thing or something, but when I googled "Sphere program editor" I got this.


Sorry to read that the engine isn't quite convenient for some of your purposes right now, though. :)


Oh, it's just 'cause I'm such a novice programmer. If I were experienced, I'd easily be able to do anything I want (I mean, Sphere uses Javascript -- look at all the stuff people do with that). It's just, for now, I have to rely so much on built-in functionality of the IDEs I use that if there's not something there, if I have to resort to doing something on my own, I have to find a workaround.



Um. I don't see why you wouldn't be able to control four characters at the same time from a single keyboard. Yes, they all come from the same single command queue, but you're pressing different keys for different characters so it's not really an issue. Heck, even several keyboards would work, as long as you set up different keys for different players. Adding controller support for this would also not be difficult.

The main hurdle with having four people on the same keyboard, though, is that most keyboard seem to have a hardware limitation where you can only press 4 to 5 keys at the same time. If you press more keys than that, they're just not sent to the system at all (so this is a problem for any software, any OS, etc). Having multiple keyboards or gamepads could solve this, easy.


For those who are experienced it's not too bad, but I don't know if a newbie can so easily do it. It's not an out-of-the-box thing for Sphere, like single player movement is.

Hmm, a good start I guess:
Code: (javascript) [Select]

function Move(name, inputs) {
    if (!IsCommandQueueEmpty(name)) return;

    if (IsKeyPressed(inputs.up)) QueuePersonCommand(name, COMMAND_MOVE_NORTH, false);
    else if (IsKeyPressed(inputs.down)) QueuePersonCommand(name, COMMAND_MOVE_SOUTH, false);
    else if (IsKeyPressed(inputs.left)) QueuePersonCommand(name, COMMAND_MOVE_WEST, false);
    else if (IsKeyPressed(inputs.right)) QueuePersonCommand(name, COMMAND_MOVE_EAST, false);
}

var inputs = [];
inputs[0] = { up: KEY_UP, down: KEY_DOWN, left: KEY_LEFT, right: KEY_RIGHT };
inputs[1] = { up: KEY_W, down: KEY_S, left: KEY_A, right: KEY_D };
inputs[2] = { up: KEY_U, down: KEY_J, left: KEY_H, right: KEY_K };
inputs[3] = { up: KEY_NUM_8, down: KEY_NUM_2, left: KEY_NUM_4, right: KEY_NUM_6 };

var players = ["player1", "player2", "player3", "player4"];

function Update() {
    for (var i = 0; i < players.length; ++i) {
        Move(players[i], inputs[i]);
    }
}

function game() {
    CreatePerson("player1", "player.rss", false);
    CreatePerson("player2", "player.rss", false);
    CreatePerson("player3", "player.rss", false);
    CreatePerson("player4", "player.rss", false);

    SetUpdateScript("Update()");
    MapEngine("map.rmp", 60);
}


I guess that's the minimum. You'll have to set the people in different places, otherwise they'll be on top of each other. Notice I didn't use AttachInput(), that means triggers won't fire, and NPC's can't be talked to. But there are ways around that. The above is a good start tho.


Whoa, thanks! See, this is always my problem -- I can look at your code there, and open up the API, and I can figure out what's going on. I can understand that code, HOWEVER, I would never have been able to come up with that code on my own in the first place. I can look and understand and even modify and improve, but I can't generate; I just don't have the mind for it.

But won't using a for-loop lock up the system?

Not that I can't change it. I was messing around in Canvas for awhile, and I figured out a way to print text character-by-character while allowing you to move your player around (ala Chrono Trigger). If you just use a for-loop, when the text starts to print, your character is frozen, and you can't control it again until the text stops printing. But I made a general-purpose iterator that constantly ran in the game loop, and just used it to print the text.

I can easily use that code here. Modified a bit of course, but I actually know how to do it ^_^

Looks like Gauntlet's back on! Thanks :)

  • Flying Jester
  • [*]
  • Verified
  • TurboSphere Developer
Re: Gauntlet clone, with extra features, and also online.
Reply #6
The main hurdle with having four people on the same keyboard, though, is that most keyboard seem to have a hardware limitation where you can only press 4 to 5 keys at the same time. If you press more keys than that, they're just not sent to the system at all (so this is a problem for any software, any OS, etc). Having multiple keyboards or gamepads could solve this, easy.


I believe that key state polling still works no matter how many keys are held down. On my laptop's keyboard and my two USB keyboards the limit is 8 keys. But that's only for events--if you poll key state (at least on Linux) you still get accurate readings of which keys are pressed. It just won't generate new events for a new key if more than 8 keys are held down at once, though it will still generate events for the eighth key.


Actually, funny story, I came across Sphere by complete, utter accident. There's this guy called Musashi who has a website of tabletop RPG and MMORPG-related rants (originally started back in 1995, so it's mostly talking about the original Everquest @_@) and in one article, he mentioned "writing a Sphere shard."

It turns out he was talking about something completely different, some sort of Everquest custom game hosting thing or something, but when I googled "Sphere program editor" I got this.



Musashi is one of the Sphere old-timers. It could have been a bona-fide Sphere reference, even if in name only.

  • Mooch
  • [*]
  • Verified
Re: Gauntlet clone, with extra features, and also online.
Reply #7

Actually, funny story, I came across Sphere by complete, utter accident. There's this guy called Musashi who has a website of tabletop RPG and MMORPG-related rants (originally started back in 1995, so it's mostly talking about the original Everquest @_@) and in one article, he mentioned "writing a Sphere shard."

It turns out he was talking about something completely different, some sort of Everquest custom game hosting thing or something, but when I googled "Sphere program editor" I got this.



Musashi is one of the Sphere old-timers. It could have been a bona-fide Sphere reference, even if in name only.


What's a Sphere "shard" though?

http://mu.ranter.net/design-theory

Here's his site. Anyone know if that's him?

  • Flying Jester
  • [*]
  • Verified
  • TurboSphere Developer
Re: Gauntlet clone, with extra features, and also online.
Reply #8
No, never mind. That Musashi is Howard Collins, the Sphere-Musashi is Chris Crawford.

Also, that page you linked has no 'Sphere Shard' text on it...

  • Mooch
  • [*]
  • Verified
Re: Gauntlet clone, with extra features, and also online.
Reply #9

No, never mind. That Musashi is Howard Collins, the Sphere-Musashi is Chris Crawford.

Also, that page you linked has no 'Sphere Shard' text on it...


Whoop. Just linked to the main page. Here's the (two, actually) refs...
http://mu.ranter.net/design-theory/general-topics/beware-the-rp-police
http://mu.ranter.net/design-theory/magic/keeping-magic-magical

  • Flying Jester
  • [*]
  • Verified
  • TurboSphere Developer
Re: Gauntlet clone, with extra features, and also online.
Reply #10
OK, so that is completely unrelated.

Ah well. The site was still a good read  :)

  • Mooch
  • [*]
  • Verified
Re: Gauntlet clone, with extra features, and also online.
Reply #11

OK, so that is completely unrelated.

Ah well. The site was still a good read  :)


Yeah, I don't know that Mu guy personally, and I can't even remember how I came across the site, and I've never even played an MMORPG, but I am an amateur RPG designer and fan, and I love his articles. Don't agree with him 100% (he's clearly hardcore into realism, I'm fine with the more fantastical), but everything he's got up there is worth reading.

@Radnen: Hmm. I'm messing around with the code you gave me, and I'm having trouble figuring out a few things. A ton of things, actually, but I don't wanna take up too much of your time or generosity, so I'll just stick with one for now.

How can I get the characters not to spawn on top of each other? I tried using SetPersonXYFloat, but it doesn't do anything. I also tried SetPersonLayer to try putting all the characters on different layers, and that doesn't work either. They all spawn at the Entry Point of the map, and if I give them Bases, become unmovable since they're all stuck in each other.

(If I use Import Image to Spriteset and don't do any further editing, they have no bases and move just freely, so I know they can be moved. It's just a matter of getting them to spawn far enough apart that their bases don't overlap. Ugh, that'll be a pain down the line -- making the characters collide with the walls, but not each other, like in the real Gauntlet games... Oh well, one thing at a time.)

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Gauntlet clone, with extra features, and also online.
Reply #12
GlovePIE looks interesting, though the political messages about green energy and all that make me not really want to download it. :P

Quote
Actually, I thought of having 16 x 16 sprites, but actually making them 16 x 32, but only drawing the sprite as 16 x 16 pixels on the lower half of the sprite area, and having the hitbox only be in that area, and using the top half for expression bubbles, like question marks and exclamation points.

There's absolutely no need to do that! Just make your sprite normally, and have your text balloon as a separate spriteset that you show at the appropriate times with CreatePerson(). This will save you a lot of hassle as you don't have to consider every single character/animation/balloon combination.

Quote
I think the main point of confusion is that it's simply not clear at all that the sprite window at the right is part of the process of making a Spriteset.

Agreed; it's not intuitive and causes confusion for pretty much everyone the first time around. I think Radnen's editor does it better (not sure; haven't been able to check it in a while).

Quote
Oh, it's just 'cause I'm such a novice programmer. If I were experienced, I'd easily be able to do anything I want (I mean, Sphere uses Javascript -- look at all the stuff people do with that). It's just, for now, I have to rely so much on built-in functionality of the IDEs I use that if there's not something there, if I have to resort to doing something on my own, I have to find a workaround.

Look, it's not just you being a novice here. I've used Sphere for a long time, and I can find plenty of faults in the API. Some things just aren't intuitive, and ultimately, they really ought to be. Then again, some of the design decisions are pretty outdated (Sphere is OLD!) and could definitely be replaced by much better solutions at this point. All that said, there's a lot I do like about Sphere's API. :)

Quote
But won't using a for-loop lock up the system?

Why would it? That loop finishes as soon as it's iterated through the entire players array... Only loops that have some condition that can never become false would make the engine get stuck. ;)


Quote
I tried using SetPersonXYFloat, but it doesn't do anything. I also tried SetPersonLayer to try putting all the characters on different layers, and that doesn't work either. They all spawn at the Entry Point of the map, and if I give them Bases, become unmovable since they're all stuck in each other.

Where are you putting SetPersonLayer and SetpersonXYFloat? You need to invoke these once the map is loaded, not before that.

There's a problem here, though:
  • Putting it before MapEngine() means it does it too early, so once the map engine opens it just sets a new (the default) position/layer.
  • Putting it after MapEngine() will make the code run once the map engine closes, which is, of course, way too late.
    So add this before MapEngine():
    Code: (javascript) [Select]
    SetDefaultMapScript(SCRIPT_ON_ENTER_MAP, function() {
    //Your code goes here!
    });

    This is from the top of my head, but it should work.
    If it doesn't work, that's Sphere's oldness at work again. Then this would work (but is much messier as it parses a string of JS instead of a neat function):
    Code: (javascript) [Select]
    SetDefaultMapScript(SCRIPT_ON_ENTER_MAP, 'your_code_here();');

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Gauntlet clone, with extra features, and also online.
Reply #13
I wouldn't use SetDefaultMapScript since it'll play each time a map is changed. I'd use:

Code: (javascript) [Select]

QueuePersonScript("player1", "code();", true);

// ...

function code() {
    SetPersonXYFloat("player1", x, y);
    SetPersonXYFloat("player2", x, y);
    SetPersonXYFloat("player3", x, y);
    SetPersonXYFloat("player4", x, y);
}


The above is just an example you'll need to set the xy's and make sure to put the QueuePersonScript after you create the person but before you call MapEngine(), and put the code() function (which you can rename to anything) somewhere else in the code file.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Gauntlet clone, with extra features, and also online.
Reply #14
Oh, hey, I never would have thought of using a person script for that. Pretty clever solution. :)