Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Timers;
  11. using System.Diagnostics;
  12.  
  13. /*
  14.  Notes:
  15.  I made the dimensions of the gameboard 400 x 600 based of the ratio of the example on the website.
  16.      
  17.      */
  18. namespace Assign5_Tetris
  19. {
  20.     public partial class Form1 : Form
  21.     {
  22.         //Global variables.
  23.         public static int R = 20;   // Row and column max. The example video was 10 x 20
  24.         public static int C = 10;
  25.         public static System.Timers.Timer timeIncriment;
  26.         public static Stopwatch theTime;
  27.         public static int RADIUS = 30;
  28.         //public static Color CURRENT_COLOR;
  29.  
  30.         //Game global variables
  31.         public bool STARTED = false;
  32.         public bool LEVELUP_TIMEGOAL = false;
  33.         public bool LEVELUP_LINEGOAL = false;
  34.         public uint LINE_COUNTER = 0;
  35.  
  36.         // True = occupied coordinate.
  37.         // False = unoccupied coordinate.
  38.         public static bool [,] State;
  39.  
  40.         public Form1()
  41.         {
  42.             InitializeComponent();
  43.  
  44.  
  45.  
  46.         }
  47.  
  48.         /* The I-piece, which is four blocks in a straight line
  49.         The L-piece, which is three blocks in a straight line, and a fourth "foot" block
  50.         The T-piece, which is three blocks in a straight line, and a fourth block in the middle of the second row
  51.         The Cube-piece, which is a 2x2 square of four blocks
  52.         The Z-block, which is like the cube-piece, except the second row is offset to the right by one
  53.         The Reverse-Z-block, which is like the cube-piece, except the second row is offset to the left by one */
  54.  
  55.         public class I_piece
  56.         {
  57.  
  58.         }
  59.         public class L_piece
  60.         {
  61.  
  62.         }
  63.         public class T_piece
  64.         {
  65.  
  66.         }
  67.         public class Cube_piece
  68.         {
  69.  
  70.         }
  71.         public class Z_piece
  72.         {
  73.  
  74.         }
  75.         public class reverseZ_Block
  76.         {
  77.  
  78.         }
  79.         public class Level
  80.         {
  81.             private uint speed = 1000; //1000 milliseconds
  82.             private uint currentLevel;
  83.  
  84.             public uint CurrentLevel { get; set; } = 1; //This short hand removed an error.
  85.             public uint Speed
  86.             {
  87.                 set { speed = value; }
  88.                 get { return speed; }
  89.             }
  90.  
  91.             public void levelUp()
  92.             {
  93.                 /* Working name: level.levelUp();
  94.                  * Purpose: 1. Increase level
  95.                  *          2. decrease speed of game clock by 50 milliseconds
  96.                             3(possibly). Points multiplier.*/
  97.  
  98.                 CurrentLevel++;
  99.  
  100.                 uint decrement_amount = 50; //50 milliseconds
  101.                 Speed -= decrement_amount;
  102.  
  103.             }
  104.  
  105.         }
  106.         private void Form1_Load(object sender, EventArgs e)
  107.         {
  108.             State = new Nullable<bool>[R, C];
  109.  
  110.             //Set the level
  111.             Level currentLevel = new Level();
  112.             uint speed = currentLevel.Speed;
  113.  
  114.             //Set the timer
  115.             theTime = new Stopwatch();
  116.             timeIncriment = new System.Timers.Timer(speed);
  117.             timeIncriment.Elapsed += IncrementTime;
  118.             timeIncriment.AutoReset = true;
  119.         }
  120.  
  121.         public void IncrementTime(object sender, ElapsedEventArgs e)
  122.         {
  123.             DisplayClock.Text = String.Format("{0:#0}:{1:00}", theTime.Elapsed.Minutes, theTime.Elapsed.Seconds);
  124.         }
  125.  
  126.         private void GameBoard_Paint_1(object sender, PaintEventArgs e)
  127.         {
  128.             using (Pen MyPen = new Pen(Color.BurlyWood))
  129.             {
  130.                 for (int i = 1; i < C; i++)
  131.                 {
  132.                     //
  133.                     // Why times i?
  134.                     e.Graphics.DrawLine(MyPen, (GameBoard.Width * i) / C, 0, (GameBoard.Width * i) / C, GameBoard.Height);
  135.                 }
  136.  
  137.                 for (int i = 1; i < R; i++)
  138.                 {
  139.                     e.Graphics.DrawLine(MyPen, 0, (GameBoard.Height * i) / R, GameBoard.Width, (GameBoard.Height * i) / R);
  140.                 }
  141.             }
  142.         }
  143.  
  144.         private void startButton_Click(object sender, EventArgs e)
  145.         {
  146.  
  147.         }
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement