Initial Commit
This commit is contained in:
8
Assets/Games/Pong.meta
Normal file
8
Assets/Games/Pong.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 501a603ad48524f2da5fc0927b30b7df
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Games/Pong/Ball.physicsMaterial2D
Normal file
14
Assets/Games/Pong/Ball.physicsMaterial2D
Normal file
@@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!62 &6200000
|
||||
PhysicsMaterial2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Ball
|
||||
serializedVersion: 2
|
||||
friction: 0
|
||||
bounciness: 1
|
||||
m_FrictionCombine: 1
|
||||
m_BounceCombine: 4
|
||||
8
Assets/Games/Pong/Ball.physicsMaterial2D.meta
Normal file
8
Assets/Games/Pong/Ball.physicsMaterial2D.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de5790510e7324e2ca7fbb524fcb37f8
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 6200000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
186
Assets/Games/Pong/Paddle.prefab
Normal file
186
Assets/Games/Pong/Paddle.prefab
Normal file
@@ -0,0 +1,186 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &6160325672362628717
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2899264478719472934}
|
||||
- component: {fileID: 594832980767784362}
|
||||
- component: {fileID: 946501248446145305}
|
||||
- component: {fileID: 6715754573185558080}
|
||||
- component: {fileID: 8492128213051010132}
|
||||
m_Layer: 0
|
||||
m_Name: Paddle
|
||||
m_TagString: Pong Paddle
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2899264478719472934
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6160325672362628717}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -8, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.3, y: 1.75, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &594832980767784362
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6160325672362628717}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!114 &946501248446145305
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6160325672362628717}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bef52777984044bd0b3bd58f57b1e458, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
speed: 400
|
||||
isPlayer1: 1
|
||||
--- !u!60 &6715754573185558080
|
||||
PolygonCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6160325672362628717}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 6200000, guid: de5790510e7324e2ca7fbb524fcb37f8, type: 2}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_ForceSendLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ForceReceiveLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ContactCaptureLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_CallbackLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_IsTrigger: 0
|
||||
m_UsedByEffector: 0
|
||||
m_CompositeOperation: 0
|
||||
m_CompositeOrder: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 1, y: 1}
|
||||
newSize: {x: 1, y: 1}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
m_Points:
|
||||
m_Paths:
|
||||
- - {x: 0.49893856, y: 0.49974525}
|
||||
- {x: -0.49788, y: 0.4993783}
|
||||
- {x: -0.8266609, y: 0.025475876}
|
||||
- {x: -0.49876922, y: -0.49950957}
|
||||
- {x: 0.50250614, y: -0.49990624}
|
||||
- {x: 0.815684, y: 0.030326055}
|
||||
m_UseDelaunayMesh: 0
|
||||
--- !u!50 &8492128213051010132
|
||||
Rigidbody2D:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6160325672362628717}
|
||||
m_BodyType: 1
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
m_Mass: 1
|
||||
m_LinearDamping: 0
|
||||
m_AngularDamping: 0.05
|
||||
m_GravityScale: 1
|
||||
m_Material: {fileID: 6200000, guid: de5790510e7324e2ca7fbb524fcb37f8, type: 2}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 5
|
||||
7
Assets/Games/Pong/Paddle.prefab.meta
Normal file
7
Assets/Games/Pong/Paddle.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 603e313b1bcbb4e7ab65d3ec701ce789
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
80
Assets/Games/Pong/Pong Goal.prefab
Normal file
80
Assets/Games/Pong/Pong Goal.prefab
Normal file
@@ -0,0 +1,80 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &6322584990785279071
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7863837557082001517}
|
||||
- component: {fileID: 2632556239085507793}
|
||||
m_Layer: 0
|
||||
m_Name: Pong Goal
|
||||
m_TagString: Pong Goal
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7863837557082001517
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6322584990785279071}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -9, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 10, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!61 &2632556239085507793
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6322584990785279071}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_ForceSendLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ForceReceiveLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ContactCaptureLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_CallbackLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_CompositeOperation: 0
|
||||
m_CompositeOrder: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_EdgeRadius: 0
|
||||
7
Assets/Games/Pong/Pong Goal.prefab.meta
Normal file
7
Assets/Games/Pong/Pong Goal.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4227f2da06efb46e1a05dfc85eb5dd39
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2269
Assets/Games/Pong/Pong.unity
Normal file
2269
Assets/Games/Pong/Pong.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Games/Pong/Pong.unity.meta
Normal file
7
Assets/Games/Pong/Pong.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c9cfa26abfee488c85f1582747f6a02
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/Games/Pong/PongBallBehavior.cs
Normal file
54
Assets/Games/Pong/PongBallBehavior.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class PongBallBehavior : MonoBehaviour
|
||||
{
|
||||
public static Vector2 score;
|
||||
|
||||
public float speed = 400f;
|
||||
public float speedIncrement = 0.1f;
|
||||
public float resetDelay = 1;
|
||||
private Rigidbody2D rb;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
StartCoroutine(Reset());
|
||||
}
|
||||
|
||||
public void IncreaseSpeed()
|
||||
{
|
||||
rb.AddForce(rb.linearVelocity.normalized * speedIncrement, ForceMode2D.Impulse);
|
||||
}
|
||||
|
||||
private IEnumerator Reset()
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
transform.position = Vector3.zero;
|
||||
rb.linearVelocity = Vector2.zero;
|
||||
|
||||
yield return new WaitForSeconds(resetDelay);
|
||||
|
||||
int direction = Random.Range(0, 2);
|
||||
rb.AddForce(new Vector2(direction == 0 ? speed : -speed, 0), ForceMode2D.Force);
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag("Pong Goal"))
|
||||
{
|
||||
if (other.transform.position.x > 0) score.x++;
|
||||
else score.y++;
|
||||
StartCoroutine(Reset());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D other)
|
||||
{
|
||||
if (other.collider.CompareTag("Pong Paddle"))
|
||||
{
|
||||
IncreaseSpeed();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Games/Pong/PongBallBehavior.cs.meta
Normal file
2
Assets/Games/Pong/PongBallBehavior.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b8dc12b87835473ba99c4efb17416e1
|
||||
27
Assets/Games/Pong/PongPaddleBehavior.cs
Normal file
27
Assets/Games/Pong/PongPaddleBehavior.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PongPaddleBehavior : MonoBehaviour
|
||||
{
|
||||
public float speed = 5f;
|
||||
public bool isPlayer1 = true;
|
||||
|
||||
private InputAction move;
|
||||
private Rigidbody2D rb;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
move = isPlayer1 ? InputSystem.actions.FindAction("Player 1 Move") : InputSystem.actions.FindAction("Player 2 Move");
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
float direction = move.ReadValue<Vector2>().y;
|
||||
if (transform.position.y >= 4 && direction > 0 || transform.position.y <= -4 && direction < 0)
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
rb.linearVelocityY = direction * speed * Time.fixedDeltaTime;
|
||||
}
|
||||
}
|
||||
2
Assets/Games/Pong/PongPaddleBehavior.cs.meta
Normal file
2
Assets/Games/Pong/PongPaddleBehavior.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bef52777984044bd0b3bd58f57b1e458
|
||||
14
Assets/Games/Pong/PongScorekeeper.cs
Normal file
14
Assets/Games/Pong/PongScorekeeper.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class PongScorekeeper : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI player1Score;
|
||||
public TextMeshProUGUI player2Score;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
player1Score.text = PongBallBehavior.score.x.ToString();
|
||||
player2Score.text = PongBallBehavior.score.y.ToString();
|
||||
}
|
||||
}
|
||||
2
Assets/Games/Pong/PongScorekeeper.cs.meta
Normal file
2
Assets/Games/Pong/PongScorekeeper.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f1d08eff5df6486186a0ab7f58cc653
|
||||
555
Assets/Games/Pong/pong-score.asset
Normal file
555
Assets/Games/Pong/pong-score.asset
Normal file
File diff suppressed because one or more lines are too long
8
Assets/Games/Pong/pong-score.asset.meta
Normal file
8
Assets/Games/Pong/pong-score.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe4d1d9c5a96040b8ac9b2e60fd96a35
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Games/Pong/pong-score.ttf
Normal file
BIN
Assets/Games/Pong/pong-score.ttf
Normal file
Binary file not shown.
21
Assets/Games/Pong/pong-score.ttf.meta
Normal file
21
Assets/Games/Pong/pong-score.ttf.meta
Normal file
@@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6b2e6e2d55c844f7829dff799923607
|
||||
TrueTypeFontImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
fontSize: 16
|
||||
forceTextureCase: -2
|
||||
characterSpacing: 0
|
||||
characterPadding: 1
|
||||
includeFontData: 1
|
||||
fontNames:
|
||||
- Pong Score
|
||||
fallbackFontReferences: []
|
||||
customCharacters:
|
||||
fontRenderingMode: 0
|
||||
ascentCalculationMode: 1
|
||||
useLegacyBoundsCalculation: 0
|
||||
shouldRoundAdvanceValue: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user