Author Topic: 2 player question  (Read 5703 times)

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
2 player question
« on: 2005-04-01, 09:14:16 PM »
This doesnt really have anything to do with scripting per se, but sort of. bluemonk, in the 2 player demo game (i think) you (or maybe durnurd) made, would the 2nd player be able to interact with special functions (the blue bars) on a map or would this need to be scripted somehow? Because one of the 2 player races I was thinking of would have heavy player interaction (both 1 & 2) with tons of special functions.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
2 player question
« Reply #1 on: 2005-04-02, 06:44:03 AM »
Interactions with tiles and functions would need to be scripted.  This might be possible by creating a second Player object and attaching it to the player 2 sprite, but I haven't experimented with that.

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
2 player question
« Reply #2 on: 2005-04-02, 06:37:25 PM »
Quote from: "bluemonkmn"
This might be possible by creating a second Player object and attaching it to the player 2 sprite, but I haven't experimented with that.


what do you mean a second player object?
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Player 2
« Reply #3 on: 2005-04-03, 07:47:08 AM »
Another instance of a GameDev player object can be created something like this, I think:
Code: [Select]
Set Plr2 = Engine.NewGameDevObj("Player")

Not sure how well that would end up working, but it's a possibility.  In order to try to make Plr2 raise the OnSpecialFunction and OnTileInteraction events like ProjectObj.GamePlayer does, you would also have to set up and sink it's events with something like this at the end of the script, where the standard 3 lines usually go:
Code: [Select]
HostObj.SinkObjectEvents HostObj.AsObject(Plr2), "Player2"

And you'd have to initialize the Plr2 Player object and hook it up to the second player's sprite in player 1's OnPlayInit event:
Code: [Select]
Set Plr2.rMap = ProjectObj.GamePlayer.rMap
' Change the player sprite to player 2 to Plr2 can find the player
' during InitPlayerSprite
ProjectObj.GamePlayer.rMap.PlayerSpriteName = "Player2"
Plr2.InitPlayerSprite

And in order to trigger the events to be checked, you would have to add code to Player 1's OnAfterMoveSprites event:
Code: [Select]
Plr2.Touch.Move Plr2.PlayerSprite.X, Plr2.PlayerSprite.Y
Plr2.Touch.TouchTest Plr2.PlayerSprite, Plr2.InterestingTiles, Plr2.FirstTouchTiles

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
2 player question
« Reply #4 on: 2005-04-04, 10:22:29 AM »
I think there may be an easier way to do it...   for my purpose I think I could just use sprites and COL_ functions at each door, that way when either player hit the sprite he'd automatically be transported.... i'm sorry, did I even say what the purpose was? One of my 2player levels was going to be a whole bunch of rooms, each with either 3 or 4 doors, and each door goes to another door of another room, but from each room you dont know where you're going, so it's like a race of chance. Let's just say it's a work in progress. Maybe i'll put like little pictures above each door or maybe in the center of each room and you have to follow a pattern or something to get to the end, like I said, not quite sure yet.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
2 player question
« Reply #5 on: 2005-04-04, 12:23:54 PM »
Easier, well, I'll leave that up to you.  Personally, I don't like the whole Sprites thing.  It's always been too complicated for me.

However, you've also got to consider the drag on performance that would create.  Lots of sprites each with a sprite collision to be checking for every frame, that could get slow.
Edward Dassmesser

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
2 player question
« Reply #6 on: 2005-04-04, 06:28:51 PM »
yea, i realized that, not sure what im gonna do.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
2 player question
« Reply #7 on: 2005-04-09, 05:42:02 PM »
actually, i did some thinking and in each room there would be either 3 or 4 doors, so thats 3-4 door sprites per room. then i figured out that each player would have to have its own set of doors in the same position, but with different colision classes. this because the sprites would be created/deleted whenever the player entered/left the room, so if both players were already in a room, and 1 leaves all the door sprites get deleted and player 2 is stuck. so even with this many sprites, figuring in 2 more sprites (player 1 & 2) thats only 8-10 sprites active on a map at once, depending on how many doors are active in the room. and i believe that last time i tried to put a lot of sprites on at once, the most was like ~50 before the game was slowed to a point where it was considered unplayable. so realistically, thats 10 sprites already in use, i could have probably 30 or so more active on the map. and since this is a race, i doubt that there will be that many, this is jst sort of a short mini game packaged in with it. but im going to work on actually finishing hte game before i worry about putting in any 2player features.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy