Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pongy Jam Challenge?

Discussion in 'General Discussion' started by Arowx, Jun 26, 2014.

  1. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    OK How long will it take you to write Pong in Unity?

    OK now prove it! o_O

    That's it who can develop Pong from scratch in Unity the fastest (with only the default assets or assets you create from scratch).

    If your in, post a comment to log your start time, then another with a link to your completed pong version and this will be used as your end time!

    GO! :D

    PS> I tried this yesterday in another thread and it took me nearly 2 hours but I'm old and slow! :p

    My 2hr Pong Attempt keys a/z - up/down

     
    Last edited: Jul 1, 2014
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    Alright, I'm in.
     
  3. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    For a minute there I thought you wanted people to create a North Korean city
     
    NomadKing likes this.
  4. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Let's do it.
     
  5. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    My pong game has quickly become very much more than just 2P pong (or I'd be done by now) so I doubt I'll be winning for promptness.
     
  6. mhtraylor

    mhtraylor

    Joined:
    Jan 13, 2013
    Posts:
    33
    Fun idea, I'm in.
     
  7. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Keep working on it.

    We can introduce categories, e.g. Fastest, Most Features, Slowest, Best Trainwreck, Best Graphics, Worst Game, Most Fun, Best Sfx, Worst Sfx, Worst Graphics ect.

    2 hours to beat!
     
  8. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    IMO I can do it in 15 minutes, which I'll do in my break later.
     
  9. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    It took me 20 minutes for 2P pong without score keeping, I'll post the webplayer when I get home, but this is all the code:

    This one just starts the ball off in random direction:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Ball : MonoBehaviour {
    5.     public float force;
    6.  
    7.     void Start () {
    8.         Vector2 vector = new Vector2(Random.Range(0f,1f),Random.Range(0f,1f)).normalized;
    9.         rigidbody2D.AddForce(vector * force);
    10.    
    11.     }
    12. }
    This is on the ends, which are just triggers off screen.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class End : MonoBehaviour {
    6.     public Transform ball;
    7.     public Vector3 startPos;
    8.  
    9.     // Use this for initialization
    10.     void Start () {
    11.         startPos = ball.position;  
    12.     }
    13.  
    14.     void OnTriggerEnter2D (Collider2D other)
    15.     {
    16.         if(other.transform == ball)
    17.         {
    18.             ball.transform.position = startPos;
    19.         }
    20.     }
    21. }
    22.  
    23.  
    This just controls the paddles.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Paddle : MonoBehaviour {
    5.     [SerializeField]
    6.     private string axisName;
    7.     [SerializeField]
    8.     private float speed;
    9.  
    10.     void Update () {
    11.         rigidbody2D.MovePosition(new Vector2(rigidbody2D.position.x,rigidbody2D.position.y + (Input.GetAxis(axisName) * speed)));
    12.     }
    13. }
    14.  
    And a physics material, I'd like to add some score tracking and some AI, and I'm not sure on the ball. It seems like it does get faster, but maybe I'd change it so when the ball is reset it ups the force.
     
  10. mhtraylor

    mhtraylor

    Joined:
    Jan 13, 2013
    Posts:
    33
    Turns out I am easily distracted. And lazy. Anyways, it's close enough: two-player, one point per score, W-S keys are player one, up-down arrows are player two. The ball bounces back into play from the goal area, in what is either a refreshing take on an old classic or a testament to my laziness.

    pongy.PNG

    Sometimes the ball doesn't bounce. That is an example of "innovation."

    I made the sprites in GIMP, sfx from bfxr, code is F#. I guess if you want to play it (who wouldn't?), you could get the html and webplayer (Dropbox doesn't have public folders anymore?).

    EDIT: Fixed the Dropbox link, per the info below. Here it is.
     
    Last edited: Jun 27, 2014
  11. zDemonhunter99

    zDemonhunter99

    Joined:
    Apr 23, 2014
    Posts:
    478
    You probably mean C# :)
     
  12. Dabeh

    Dabeh

    Joined:
    Oct 26, 2011
    Posts:
    1,614
    F# works in Unity.

    On topic though, I'm going to participate. I have to work soon, but I might be able to get something nice in a couple hours. Otherwise, I'll edit this post with the time I want to stop at and then when I continue again. I'm not going for "super duper fast", but I will provide the time that I get a basic build working.

    TLDR: Starting now.
     
  13. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    @TylerPerry Wow 20 mins without scorekeeping nice one, but it would only take a couple extra lines of code and you would have scorekeeping.

    How have you limited your bats to the screen?

    @mhtraylor best looking attempt so far and you can share a html link to the webplayer so people can play your game without downloading the file - in windows it's right click - copy public link.

    How long did it take as your posts time stamps make it look like 12 hours?
     
  14. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    I just had some 2D box colliders on top and bottom of the screen, as Rigidbody2D.MovePosition doesn't do through them, I did have issues with my paddles bouncing a little off of the top and bottom, but didn't worry about it.

    I was going to add score keeping, but our breaks are only 15minutes and I'd already gone over :D I would have just had a GUIText and had a little counter that goes up whenever the ball enters the trigger.
     
  15. Dabeh

    Dabeh

    Joined:
    Oct 26, 2011
    Posts:
    1,614
    Done, took 1 hour and 26 minutes. Will be improving it later on with some features, the bottom and top boundaries move out as they're hit(this is on purpose, I've clamped their position so they can't get too far but I wanted it to get harder as you go) and the ball speeds up the longer you go. I'm not using the inbuilt physics BTW, not enough precision. This is the reason I took a little longer, I didn't really settle for any of those small problems that could have taken 40 minutes off my time. There is no random angle at the start of the match, I change the angle of the ball based on how you hit it. It starts with a straight trajectory.


    I'm going to be adding some very nice effects soon, but as I can't use other assets I have to resort to coding a lot of these complex effects by hand. I'll edit this post to reflect when I begin on that stage.

    BasicPicture.png
    Since Dropbox no longer lets me just give a link, here's the two files.

    https://www.dropbox.com/s/t9rorgtesjeq2nu/Build.html
    https://www.dropbox.com/s/eicxc390fpbsnv5/Build.unity3d?m=

    (Includes AI)
     
    Last edited: Jun 27, 2014
  16. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Nice work!

    You do know that using dropbox if you...

    1 - Go to the html file in the dropbox folder in explorer.
    2 - Right click and choose share as link.
    3 - Then trim off the s in the https: part of the link it works.

    Or at least it does for me?!

    My Pong it's actually 3D! (in orthographic view ;))

    Hey no one has tried for a 3D version of pong yet?!
     
  17. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    I think they updated it very recently to take away that functionality. Someone should start a thread looking for alternatives, I'm to sleepy though.

    EDIT: Ok, actually they just are not doing it right, just change "www" to "dl" and it works :D
     
  18. mhtraylor

    mhtraylor

    Joined:
    Jan 13, 2013
    Posts:
    33
    @Arowx -- mine took at least 3 hours actually work. Which is sad, considering it's broken (shouldn't have used Physics, I think). Ended up having to go to do real work yesterday, "finished" it when I got back :(.
     
  19. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    Eh, what the hell.

    Up/Down controls player 2, W/S controls player 1. First to score to 6 wins.

    I have more features planned but this is at least released.

    http://murgilod.itch.io/pong

    My ultimate goal here is to create a more fully featured pong clone entirely in Unity. So no outside assets or anything. That includes graphics, fonts, and sounds.
     
  20. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    @Murgilod nice one, looks very close to the original and good idea to put it up on itch.io. How long did it take as you started yesterday about 1pm?
     
  21. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    Honestly, there's probably around 6 hours of work in there. I had some errands to run and had to call around to dentists after chipping a filling.

    I also deleted/rewrote a LOT of its base code, much of which isn't in there (like procedural sound generation and AI)
     
  22. mhtraylor

    mhtraylor

    Joined:
    Jan 13, 2013
    Posts:
    33
    Murgilod's is very nice, classic.

    So I tried a 3D version this morning... more like a racquetball court than Pong, I guess. Took around 2.5 hours, but there is no polish, sound, or anything and therefore gameplay is extremely difficult. It's hard to determine where the ball will be headed, I should add something for that.

    WASD for blue player, Arrow keys for red.
    pongy2.PNG
     
  23. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Yay our first 3D version, well done!

    Remember it's a Jam so you can improvise and enhance Pong!

    What would your ideal version of Pong look like, CGI robots, liquids, strange physics, raytraced glass, particle madness?

    No don't tell me have a go at creating that vision in Unity, then show us your results and tell us how long it took!
     
  24. Dabeh

    Dabeh

    Joined:
    Oct 26, 2011
    Posts:
    1,614
    I really..really want to post what I have so far but let me just say that it's a lot different to my old version, an extra couple hours did wonders...and it has a couple things on that list along with other stuff. Sadly I need to get some work done so I have to take a break.
     
  25. Uberpete

    Uberpete

    Joined:
    Jan 16, 2014
    Posts:
    78
    CHALLENGE ACCEPTED
     
  26. Uberpete

    Uberpete

    Joined:
    Jan 16, 2014
    Posts:
    78
    Finished in 20 (ish) minutes! That orangey thing is an invisibility pickup.

    Pong.png
     
  27. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    I got bored so I worked on Pong again.

    http://murgilod.itch.io/pong

    CHANGELOG v0.04b
    • Uncommented the code that was keeping boob physics from activating
    CHANGELOG v0.03b
    • Realistic volley simulations
    CHANGELOG v0.02b
    • Ball now accelerates less rapidly
    • 5.1 dolby digital surround sound
    Procedural audio code shamelessly stolen from here as I could not figure out for the life of me how to do it myself.
     
    Last edited: Jun 30, 2014
  28. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Nice one @Murigilod, you're very close to the original.

    Found this of the original arcade machine, the bats are quite small, the screen is closer to square and don't forget that plasma screen motion blur, or cathode ray tube curved reflections, or the cabinet if anyone wants to take it 3D!

    It also uses a pay per play business model.

     
  29. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    I was going less off the original arcade machine and more off a (now non-fuctional) device I picked up at a flea market a very long time ago.



    It's obviously not a perfect recreation, but more a "faithful successor."
     
  30. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    LOL, so will you add the other game modes?
     
  31. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    Why, such an idea would be madness

     
  32. P_Mason

    P_Mason

    Joined:
    Apr 6, 2014
    Posts:
    14
    Starting...
     
  33. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    This is mega awesome @Arowx
     
  34. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    I should have just written my own custom physics system instead of using Unity's because wow, this is the most inaccurate thing I've ever used.
     
  35. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Just write your own OnCollisionEnter() handler on the ball!

    Or if you want to go old school SetPixel()
     
    Last edited: Jun 30, 2014
  36. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    I might go even sassier and write it so that nearly the entire game is calculated in a shader, but that's fun for another day I think.
     
  37. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Now that I would love to see, a spinning cube with a Pong game shader!
     
  38. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    What issues have people had with the physics? Mine was super dodgy because I didn't bother with much except for core pong gameplay, but with some tweaking it wouldn't be hard to get the physics to work perfectly.
     
  39. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Worked on my project for about 2 hours or so. It has an AI you can go up against if you don't have anyone around to verse (mostly everybody here including myself). Player 1 keys are 'W' and 'S', Player 2 keys are 'up' and 'down'. The game ends when a player hits 10 points.

    Some images for your eyeballs,

     
    Last edited: Jul 1, 2014
  40. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Nice one!

    @TylerPerry, I had a few hiccups with the physics, and physics materials but playing about with it a bit got it working ok.

    Physics Tips:
    1. Turn off Gravity :eek:
    2. Colliders don't need rigidbodies, especially walls o_O
    3. Make your own physics material ;)
    4. Test and repeat until just right :cool:
     
  41. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Uploaded my game to the android store. Pretty much the same game, but with touch input.
     
  42. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    WARNING! Pong is trademarked by Atari. I would recommend a rename before releasing any free pong clones!
     
    Last edited: Jul 2, 2014
  43. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,081
    http://murgilod.itch.io/bong

    Fixed.
     
  44. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Renamed it to 'Super Disco Ping!'
     
  45. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106
  46. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    100100100100100001100
     
  47. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    847
    This should be made a regular thing with some really old classics like Breakout, Space Invaders or Pacman.

    "Grumpy Old Farts Jam"
     
    Rodolfo-Rubens, TylerPerry and Aurore like this.
  48. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106

    I approve of this.
     
  49. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,197
    Startingg! ^___^
     
  50. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,197
    Almost finishing mine, but it took a lot of time, I was trying to figure out how I was going to make the rounded track of the paddles:


    the answer was animations! :)