10.03.2019 - Round 1 results of our "A Love Letter For FreeBASIC" game dev competition have been published. Please be sure to check the results thread: http://games.freebasic.net/forum/index.php?topic=629.0. Don't forget that the competition is continuing with a round 2, lasting till 29th of April, 300 USD first prize. Stay tuned!

Author Topic: Breakout Multiplayer: How?  (Read 15525 times)

KristopherWindsor

  • Forum Sage
  • *****
  • Posts: 363
  • The Thirsty Smiley
    • View Profile
    • Reddit/r/pics
    • Email
Breakout Multiplayer: How?
« on: July 16, 2008, 01:18:14 AM »
I was thinking that in the 2-player mode, one player will have the mouse, and the other will have the keyboard.
There will be twice as many paddles, and the paddles will be half the width (compared to the single player version).
To simplify the programming, only player one will control the ball and missile launching (with the mouse button).

Does anyone have a better idea?
Would it be practical to use USB game controllers to support more than two players?

 ;D

Tusike

  • Novice
  • ***
  • Posts: 95
    • MSN Messenger - varnaipeti@hotmail.com
    • View Profile
    • Email
Re: Breakout Multiplayer: How?
« Reply #1 on: July 16, 2008, 07:23:32 AM »
How does the mouse work? Is the x coordinate of the paddle replaced by the mouse's every time, or is a number added or subtracted from the paddle's x based on the mouse's x?

Difference: First option allows fast movement of paddle
Second will have the paddle "slowly" moving towards the mouse

If you plan on using arrow keys for the second player I suggest using the second option.

Btw, how can you have so much bricks without a grid with that many balls, and still run the same speed as if only one ball where present?

-Tusike

KristopherWindsor

  • Forum Sage
  • *****
  • Posts: 363
  • The Thirsty Smiley
    • View Profile
    • Reddit/r/pics
    • Email
Re: Breakout Multiplayer: How?
« Reply #2 on: July 16, 2008, 12:10:49 PM »
How does the mouse work? Is the x coordinate of the paddle replaced by the mouse's every time, or is a number added or subtracted from the paddle's x based on the mouse's x?

Difference: First option allows fast movement of paddle
Second will have the paddle "slowly" moving towards the mouse

If you plan on using arrow keys for the second player I suggest using the second option.

I already have that for the one-player mode; there are control:x/y/click variables, and the paddles move towards them.

Code: [Select]
  With utility_mouse
    .update()
    If .c.sx <> .p.sx Or .c.sy <> .p.sy Then game.input_usemouse = true
  End With
 
  With game
    .input_key_x = Abs(Multikey(&h4D)) - Abs(Multikey(&h4B))
    .input_key_y = Abs(Multikey(&h50)) - Abs(Multikey(&h48))
    If .input_key_x <> 0 Or .input_key_y <> 0 Then .input_usemouse = false
  End With
 
  With game
    If .input_usemouse Then
      .control_x = utility_mouse.c.sx
      .control_y = utility_mouse.c.sy
    Else
      .control_x += .input_key_x * .input_keyspeed
      If .control_x < 0 Then .control_x = 0
      If .control_x >= data_screen.default_sx Then .control_x = data_screen.default_sx - 1
      .control_y += .input_key_y * .input_keyspeed
      If .control_y < 0 Then .control_y = 0
      If .control_y >= data_screen.default_sy Then .control_y = data_screen.default_sy - 1
    End If
    .control_click = utility_mouse.c.b > 0 Or Multikey(fb.sc_space)
  End With

Quote
Btw, how can you have so much bricks without a grid with that many balls, and still run the same speed as if only one ball where present?

-Tusike

What? I don't understand. :P
The game is optimized (all bricks are drawn on the same image, so they can be drawn to the screen with one Put call) and has a good framerate control object. :D

Lachie Dazdarian

  • Double dipper
  • Administrator
  • Forum Sage
  • *****
  • Posts: 1308
    • Yahoo Instant Messenger - lachie13
    • View Profile
    • The Maker Of Stuff
    • Email
Re: Breakout Multiplayer: How?
« Reply #3 on: July 16, 2008, 04:47:25 PM »
I'm still not clear on the gameplay to give a constructive answer on this. But I don't see much fun in only launching the balls and fireing the missles. For me, the only game where mouse and keyboard make sense is where mouse involves aiming or steering.
"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist

KristopherWindsor

  • Forum Sage
  • *****
  • Posts: 363
  • The Thirsty Smiley
    • View Profile
    • Reddit/r/pics
    • Email
Re: Breakout Multiplayer: How?
« Reply #4 on: July 16, 2008, 08:03:43 PM »
I'm still not clear on the gameplay to give a constructive answer on this. But I don't see much fun in only launching the balls and firing the missiles. For me, the only game where mouse and keyboard make sense is where mouse involves aiming or steering.

I think you misunderstood. My idea was (slightly changed):
- Player 1 controls half of the paddles with the mouse
- Player 2 controls the other half of the paddles with the keyboard
- If either player presses the button to launch / fire, then all lasers fire, and all balls are released (so it would make sense for only Player 1 to bother holding the button down)

Tusike

  • Novice
  • ***
  • Posts: 95
    • MSN Messenger - varnaipeti@hotmail.com
    • View Profile
    • Email
Re: Breakout Multiplayer: How?
« Reply #5 on: July 16, 2008, 11:57:44 PM »
Are you saying that it's faster to redraw the whole screen every frame than to just "undraw" things that move and draw them again?

I won't be here for the next month.
Happy programming!

-Tusike

Leonheart

  • Novice
  • ***
  • Posts: 54
    • Yahoo Instant Messenger - tenchu_shinobi_taizen
    • View Profile
    • Xaviorsoft Studios
Re: Breakout Multiplayer: How?
« Reply #6 on: July 17, 2008, 12:18:08 AM »
Better make small lan support for multiplayer. So maybe can get all 32 player paddle at one screen. Make a 32 paddle in one row, so the ball can't escape. :P
Even just one flap of butterfly can make storm in the world.

KristopherWindsor

  • Forum Sage
  • *****
  • Posts: 363
  • The Thirsty Smiley
    • View Profile
    • Reddit/r/pics
    • Email
Re: Breakout Multiplayer: How?
« Reply #7 on: July 17, 2008, 12:38:21 AM »
Better make small lan support for multiplayer. So maybe can get all 32 player paddle at one screen. Make a 32 paddle in one row, so the ball can't escape. :P

I think LAN is beyond the scope of the casual / downloadable / shareware genre. ;)

KristopherWindsor

  • Forum Sage
  • *****
  • Posts: 363
  • The Thirsty Smiley
    • View Profile
    • Reddit/r/pics
    • Email
Re: Breakout Multiplayer: How?
« Reply #8 on: July 17, 2008, 12:46:30 AM »
Are you saying that it's faster to redraw the whole screen every frame than to just "undraw" things that move and draw them again?

I won't be here for the next month.
Happy programming!

-Tusike

I didn't say that; I said it is faster than redrawing each of the 500 bricks individually each frame. ;)
You'll need to see a video or demo of this game to see all the effects, but if you saw how much was moving on the screen you would see it is impossible to just undraw a few things.
All of the bricks can be animated, there are particles everywhere, the bricks and paddles fly all over the screen when broken, and the entire screen is drawn with "put alpha, alphavalue," so one frame is blended onto the next. :)

Actually I was surprised; on some levels the game can get > 40FPS at 1680 * 1050. :D :D :D