Skip to main content

News

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

0 Members and 1 Guest are viewing this topic.
  • Mooch
  • [*][*][*]
Re: Gauntlet clone, with extra features, and also online.
Reply #60

If you are wondering about recursion errors check your code out:
Code: (javascript) [Select]

function WriteSomething(){
    font.drawText(0,0,"All this program does is display this message.");
    WriteSomething(); // issue here.
}


Notice you are calling the same function within itself? It is recursive in that fashion, so naturally, it'll go on forever and run out of stack memory. Stack memory is the memory used for function calls. There is a limited space of stack memory, but that doesn't mean you can have a limited number of functions. When you removed this it worked. Now you know what recursion is :). (It's not a bug or a bad thing. In fact if you can use it right it's awesome, but it is also tricky).


My problem was that I put the whiletrue loop in the function, not the game loop. Here's my new, working code...

Code: (javascript) [Select]
var font = GetSystemFont();

function WriteSomething(){
font.drawText(0,0,"All this program does is display this message.");
FlipScreen();}

function game(){
while (true){
WriteSomething();}}

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: Gauntlet clone, with extra features, and also online.
Reply #61
@Mooch - AttachPlayerInput(entity_name, player_index) allows choosing to attach up to 4 different players to entities. IIRC, this is how the Bomberman demo accomplished it.

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

@Mooch - AttachPlayerInput(entity_name, player_index) allows choosing to attach up to 4 different players to entities. IIRC, this is how the Bomberman demo accomplished it.


...

...

How did we miss that? Exactly? Me and DaVince and Radnen and whoever else have been posting in this topic lamenting no multiplayer input for days now, and none of us noticed that?

Obviously, if you try to have that all on the same keyboard, you get problems; one person can't move right while another's moving, etc. Presumably, though, if you're playing online with others, that shouldn't be a problem. Or if you're using multiple gamepads or keyboards.

Though I'd still like to try to get my Multitap Hack to work. Then you could have an arbitrary amount of input coming from one keyboard.

Also, Gauntlet clone's still canned. I'm working on something else. Not gonna post anything 'til I have something to show off. Trying to work out all the code on my own, too, and not be asking so many questions and taking up so much of everyone's time. It's going good, I'm OOP-ing!

...

Still can't believe I missed that. Although the Wiki's got so many redlinks, and the Help file in sphere/docs/contributed is incomplete and presumably from an older version of Sphere (there's no AttachPlayerInput); I've read through what's documented of the API twice now and I still don't understand half of it.

Thanks for pointing that out.

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Gauntlet clone, with extra features, and also online.
Reply #63
Quote
How did we miss that? Exactly? Me and DaVince and Radnen and whoever else have been posting in this topic lamenting no multiplayer input for days now, and none of us noticed that?


There's always been multiplayer input, I never said never. ;)

What I didn't know is if there existed a function in the API that did that for you. I'm still a bit skeptical, but it seems plausible.
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

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Gauntlet clone, with extra features, and also online.
Reply #64
Yeah, just looked it up myself, and it turns out the normal AttachInput() is just a convenience function.  Straight from api.txt for Sphere 1.5:

Code: [Select]
AttachPlayerInput(person_entity, player_index)
  - makes the 'person_entity' respond to the input
    Currenty player_index has to be from zero to four (max four players)
    Note: AttachInput is equilivent to AttachPlayerInput(person_entity, 0)


Which when I think about it, does make sense seeing as config.exe allows you to map inputs for 4 players.  It'd be stupid if AttachInput only worked for one player.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Gauntlet clone, with extra features, and also online.
Reply #65
I remember when config.exe didn't have that extra input stuff, but I'm an oldie. Which was why I was skeptical. I never used it!
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
  • [*][*][*]
Re: Gauntlet clone, with extra features, and also online.
Reply #66
The lesson here is, re-familiarize yourself with your tools every once in awhile. You never know when they've sprouted new features ;)

Re: Gauntlet clone, with extra features, and also online.
Reply #67
Well, the latest it could have been added was 2008. And I think it existed before that, at least in 2006 when a certain one of Flikky's tutorials was written.