├── config └── dvd.fgd ├── README.md ├── ui ├── dvd.png └── dvd.png.meta ├── sounds ├── close.wav ├── damn.wav ├── close.vsnd_c ├── damn.sound_c ├── damn.vsnd_c ├── yooouuu.wav ├── close.sound_c ├── yooouuu.vsnd_c ├── yooouuu.sound_c ├── close.encoding.txt ├── damn.encoding.txt ├── yooouuu.encoding.txt ├── close.sound ├── damn.sound └── yooouuu.sound ├── .gitattributes ├── .gitignore ├── code ├── Properties │ └── launchSettings.json ├── DVDPanel.cs ├── Hud.scss ├── Game.cs ├── Hud.cs └── DVDEntity.cs ├── LICENSE └── .addon /config/dvd.fgd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DVD 2 | DVD 3 | 4 | (DVD) -------------------------------------------------------------------------------- /ui/dvd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/ui/dvd.png -------------------------------------------------------------------------------- /sounds/close.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/close.wav -------------------------------------------------------------------------------- /sounds/damn.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/damn.wav -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /sounds/close.vsnd_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/close.vsnd_c -------------------------------------------------------------------------------- /sounds/damn.sound_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/damn.sound_c -------------------------------------------------------------------------------- /sounds/damn.vsnd_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/damn.vsnd_c -------------------------------------------------------------------------------- /sounds/yooouuu.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/yooouuu.wav -------------------------------------------------------------------------------- /sounds/close.sound_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/close.sound_c -------------------------------------------------------------------------------- /sounds/yooouuu.vsnd_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/yooouuu.vsnd_c -------------------------------------------------------------------------------- /sounds/yooouuu.sound_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rndtrash/dvd/master/sounds/yooouuu.sound_c -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | code/obj 2 | code/Properties 3 | code/dvd.csproj 4 | code/accesslist.txt 5 | .intermediate/ 6 | tools*.bin -------------------------------------------------------------------------------- /ui/dvd.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "clampu": false, 3 | "clampv": false, 4 | "clampw": false, 5 | "nolod": true, 6 | "nomip": true, 7 | "nocompress": true, 8 | "brightness": 1 9 | } -------------------------------------------------------------------------------- /sounds/close.encoding.txt: -------------------------------------------------------------------------------- 1 | 2 | { 3 | loop = false 4 | } -------------------------------------------------------------------------------- /sounds/damn.encoding.txt: -------------------------------------------------------------------------------- 1 | 2 | { 3 | loop = false 4 | } -------------------------------------------------------------------------------- /sounds/yooouuu.encoding.txt: -------------------------------------------------------------------------------- 1 | 2 | { 3 | loop = false 4 | } -------------------------------------------------------------------------------- /code/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "dvd": { 4 | "commandName": "Executable", 5 | "executablePath": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\sbox\\sbox.exe", 6 | "commandLineArgs": "\u002Bdeveloper \u002Bsw -noassert -tools" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /code/DVDPanel.cs: -------------------------------------------------------------------------------- 1 | using Sandbox.UI; 2 | 3 | namespace DVD; 4 | 5 | public partial class DVDPanel : Panel 6 | { 7 | public override void Tick() 8 | { 9 | Style.Left = Length.Percent( DVDEntity.Instance.xConverted * 100 ); 10 | Style.Top = Length.Percent( DVDEntity.Instance.yConverted * 100 ); 11 | 12 | Style.BackgroundTint = DVDEntity.HexColors[DVDEntity.Instance.currentColor]; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sounds/close.sound: -------------------------------------------------------------------------------- 1 | 2 | { 3 | data = 4 | { 5 | sounds = 6 | [ 7 | "sounds/close.vsnd", 8 | ] 9 | ui = true 10 | volume = 1.0 11 | volumerandom = 0.0 12 | pitch = 1.0 13 | pitchrandom = 0.0 14 | distancemax = 2000.0 15 | selectionmode = "3" 16 | } 17 | } -------------------------------------------------------------------------------- /sounds/damn.sound: -------------------------------------------------------------------------------- 1 | 2 | { 3 | data = 4 | { 5 | sounds = 6 | [ 7 | "sounds/damn.vsnd", 8 | ] 9 | ui = true 10 | volume = 1.0 11 | volumerandom = 0.0 12 | pitch = 1.0 13 | pitchrandom = 0.0 14 | distancemax = 2000.0 15 | selectionmode = "3" 16 | } 17 | } -------------------------------------------------------------------------------- /sounds/yooouuu.sound: -------------------------------------------------------------------------------- 1 | 2 | { 3 | data = 4 | { 5 | sounds = 6 | [ 7 | "sounds/yooouuu.vsnd", 8 | ] 9 | ui = true 10 | volume = 1.0 11 | volumerandom = 0.0 12 | pitch = 1.0 13 | pitchrandom = 0.0 14 | distancemax = 2000.0 15 | selectionmode = "3" 16 | } 17 | } -------------------------------------------------------------------------------- /code/Hud.scss: -------------------------------------------------------------------------------- 1 | RootPanel { 2 | width: 100%; 3 | height: 100%; 4 | background-color: black; 5 | margin: 0; 6 | pointer-events: all; 7 | padding: 0 510px 305px 0; 8 | } 9 | 10 | DVDPanel { 11 | transition: left 0.01s linear, top 0.01s linear; 12 | background-image: url(ui/dvd.png); 13 | background-repeat: no-repeat; 14 | background-size: 510px 305px; 15 | width: 510px; 16 | height: 305px; 17 | margin: 0; 18 | padding: 0; 19 | } 20 | 21 | .scoreboard { 22 | .corners { 23 | width: 90px; 24 | text-align: right; 25 | } 26 | } -------------------------------------------------------------------------------- /code/Game.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Sandbox; 3 | 4 | namespace DVD; 5 | 6 | public class Game : GameManager 7 | { 8 | public static Game Instance { get; internal set; } 9 | 10 | private IList _clients = new List(); 11 | 12 | public Game() 13 | { 14 | if ( Sandbox.Game.IsServer ) 15 | { 16 | _ = new DVDEntity(); 17 | _ = new HudEntity(); 18 | } 19 | 20 | Instance = this; 21 | } 22 | 23 | public override void ClientJoined( IClient cl ) 24 | { 25 | base.ClientJoined( cl ); 26 | 27 | _clients.Add( cl ); 28 | } 29 | 30 | public override void ClientDisconnect( IClient cl, NetworkDisconnectionReason reason ) 31 | { 32 | base.ClientDisconnect( cl, reason ); 33 | 34 | _clients.Remove( cl ); 35 | } 36 | 37 | public static void AddScore() 38 | { 39 | foreach ( var cl in Instance._clients ) 40 | { 41 | if ( !cl.IsValid ) 42 | continue; 43 | 44 | cl.AddInt( "corners" ); 45 | } 46 | Log.Error( "TODO: leaderboards" ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Ivan Kuzmenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.addon: -------------------------------------------------------------------------------- 1 | { 2 | "Title": "DVD", 3 | "Type": "game", 4 | "Org": "tesa", 5 | "Ident": "dvd", 6 | "Tags": "meme dvd", 7 | "Schema": 1, 8 | "HasAssets": true, 9 | "AssetsPath": "", 10 | "ResourcePaths": [ 11 | "/ui/dvd.png" 12 | ], 13 | "HasCode": true, 14 | "CodePath": "code", 15 | "PackageReferences": [], 16 | "EditorReferences": null, 17 | "Metadata": { 18 | "MapList": [], 19 | "PerMapRanking": false, 20 | "LeaderboardType": "Descending", 21 | "RankType": "Increment", 22 | "MapSelect": "Empty", 23 | "GameNetworkType": "Multiplayer", 24 | "MaxPlayers": 64, 25 | "MinPlayers": 1, 26 | "Collision": { 27 | "Defaults": {}, 28 | "Pairs": [] 29 | }, 30 | "Summary": "Watch the bouncing DVD logo with your friends!", 31 | "Description": "Watch the bouncing DVD logo with your friends!\r\nThis gamemode has chat and the position of bouncing logo is the same for every player!", 32 | "Public": true, 33 | "CsProjName": "", 34 | "ControlModes": { 35 | "Keyboard": true, 36 | "Gamepad": true 37 | }, 38 | "Compiler": { 39 | "RootNamespace": "DVD", 40 | "DefineConstants": "SANDBOX;ADDON;DEBUG", 41 | "NoWarn": "1701;1702;1591;" 42 | }, 43 | "ReplaceTags": "meme dvd coop", 44 | "HttpAllowList": null 45 | } 46 | } -------------------------------------------------------------------------------- /code/Hud.cs: -------------------------------------------------------------------------------- 1 | using Sandbox.UI; 2 | using Sandbox.UI.Construct; 3 | 4 | namespace DVD; 5 | 6 | public partial class HudEntity : Sandbox.HudEntity 7 | { 8 | public class DVDScoreboard : Scoreboard where T : ScoreboardEntry, new() 9 | { 10 | protected override void AddHeader() 11 | { 12 | Header = Add.Panel( "header" ); 13 | Header.Add.Label( "Name", "name" ); 14 | Header.Add.Label( "Corner Hits Seen", "corners" ); 15 | Header.Add.Label( "Ping", "ping" ); 16 | } 17 | } 18 | 19 | public class DVDScoreboardEntry : ScoreboardEntry 20 | { 21 | Label CornerHitsSeen; 22 | 23 | public DVDScoreboardEntry() 24 | { 25 | AddClass( "entry" ); 26 | 27 | CornerHitsSeen = Add.Label( "0", "corners" ); 28 | Kills.Delete( true ); 29 | Deaths.Delete( true ); 30 | Ping.Delete( true ); 31 | Ping = Add.Label( "", "ping" ); 32 | } 33 | 34 | public override void UpdateData() 35 | { 36 | PlayerName.Text = Client.Name; 37 | CornerHitsSeen.Text = Client.GetInt( "corners" ).ToString(); 38 | Ping.Text = Client.Ping.ToString(); 39 | SetClass( "me", Client == Sandbox.Game.LocalClient ); 40 | } 41 | } 42 | 43 | public HudEntity() 44 | { 45 | if ( !Sandbox.Game.IsClient ) 46 | { 47 | return; 48 | } 49 | 50 | RootPanel.StyleSheet.Load( "/Hud.scss" ); 51 | 52 | RootPanel.AddChild(); 53 | RootPanel.AddChild(); 54 | RootPanel.AddChild(); 55 | RootPanel.AddChild>(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /code/DVDEntity.cs: -------------------------------------------------------------------------------- 1 | using Sandbox; 2 | 3 | namespace DVD; 4 | 5 | public partial class DVDEntity : Entity 6 | { 7 | public static DVDEntity Instance { get; internal set; } 8 | 9 | public static readonly Color[] HexColors = new[] { 10 | Color.Parse("#be00ff") ?? Color.Magenta, 11 | Color.Parse("#00feff") ?? Color.Magenta, 12 | Color.Parse("#ff8300") ?? Color.Magenta, 13 | Color.Parse("#0026ff") ?? Color.Magenta, 14 | Color.Parse("#fffa01") ?? Color.Magenta, 15 | Color.Parse("#ff2600") ?? Color.Magenta, 16 | Color.Parse("#ff008b") ?? Color.Magenta, 17 | Color.Parse("#25ff01") ?? Color.Magenta 18 | }; 19 | 20 | [Net] public float xConverted { get; set; } 21 | [Net] public float yConverted { get; set; } 22 | [Net] public int currentColor { get; set; } 23 | 24 | public Sound currentSound { get; internal set; } 25 | 26 | // X & Y in [0; 1] 27 | private float X = 1; 28 | private float Y = 1; 29 | 30 | //[Net] 31 | float xDir = 1.0f; 32 | //[Net] 33 | float yDir = 1.0f; 34 | readonly float speed = 100f; 35 | bool hyped = false; 36 | Vector2 cornerOfInterest = new(0, 0); 37 | 38 | public override void Spawn() 39 | { 40 | base.Spawn(); 41 | 42 | Transmit = TransmitType.Always; 43 | 44 | SetCornerOfInterest(); 45 | 46 | Instance = this; 47 | } 48 | 49 | public override void ClientSpawn() 50 | { 51 | base.ClientSpawn(); 52 | 53 | Instance = this; 54 | } 55 | 56 | [GameEvent.Tick.Server] 57 | public void Tick() 58 | { 59 | X = MathX.Clamp(X + xDir * speed * Time.Delta, 0, 1920); 60 | Y = MathX.Clamp(Y + yDir * speed * Time.Delta, 0, 1080); 61 | 62 | xConverted = X / 1920.0f; 63 | yConverted = Y / 1080.0f; 64 | 65 | if (!hyped) 66 | { 67 | if (Vector3.DistanceBetween(new Vector3(cornerOfInterest, 0), new Vector3(X, Y, 0)) < 300.0f) 68 | { 69 | hyped = true; 70 | PlayScreenSound(To.Everyone, "close"); 71 | } 72 | } 73 | 74 | var ts = TouchSides(); 75 | var tcf = TouchCeilFloor(); 76 | if (ts || tcf) 77 | { 78 | NextColor(); 79 | if (ts) 80 | xDir *= -1; 81 | if (tcf) 82 | yDir *= -1; 83 | if (ts && tcf) 84 | { 85 | Game.AddScore(); 86 | PlayScreenSound(To.Everyone, "yooouuu"); 87 | } 88 | else if (hyped) 89 | { 90 | PlayScreenSound(To.Everyone, "damn"); 91 | } 92 | hyped = false; 93 | 94 | SetCornerOfInterest(); 95 | } 96 | } 97 | 98 | [ClientRpc] 99 | public static void PlayScreenSound(string sound) 100 | { 101 | Log.Info($"playing sound {sound}"); 102 | Instance.currentSound.Stop(); 103 | Instance.currentSound = Sound.FromScreen(sound); 104 | } 105 | 106 | private void NextColor() 107 | { 108 | currentColor = (currentColor + 1) % HexColors.Length; 109 | } 110 | 111 | private void SetCornerOfInterest() 112 | { 113 | cornerOfInterest = new Vector2(xDir < 0 ? 0 : 1920, yDir < 0 ? 0 : 1080); 114 | } 115 | 116 | private bool TouchSides() 117 | { 118 | return ((int)X <= 0) || ((int)X >= 1920); 119 | } 120 | 121 | private bool TouchCeilFloor() 122 | { 123 | return ((int)Y <= 0) || ((int)Y >= 1080); 124 | } 125 | } 126 | --------------------------------------------------------------------------------