using SpriteStacker.Properties; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace SpriteStacker { public partial class Form1 : Form { public static Thread MainThread; public static bool running = true; Model model = new Model(25, 25); public double LastFT = 0; public Form1() { InitializeComponent(); ResizeDisplay(); MainThread = new Thread(mainThread); MainThread.SetApartmentState(ApartmentState.STA); model.SetBitmapLayers(new Bitmap[] { Resources._1, Resources._2, Resources._3, Resources._4, Resources._5, Resources._6, Resources._7, Resources._8, Resources._9, Resources._10, Resources._11, Resources._12, Resources._13, Resources._14, Resources._15, Resources._16, Resources._17, Resources._18, Resources._19, Resources._20, Resources._21, Resources._22, Resources._23, Resources._24, Resources._25, Resources._26 }); //model.AddLayers(20); Random rnd = new Random(); Color[] colors = new Color[] { Color.FromArgb(255,128,128) }; for (int i = 0; i < 150; i++) { for(int j = 0; j < 150; j++) { //int Y = rnd.Next(0, 21); //model.SetData(rnd.Next(0, 25), rnd.Next(0, 25),Y , new Voxel(Color.FromArgb((int)(180 * ( (Y + 1.0) / 22.0 )), (int)(255 * ((Y + 1.0) / 22.0)), (int)(128 * ((Y + 1.0) / 22.0))))); } } //model.DrawLayersToImages(); MainThread.Start(); } public void mainThread() { LastFT = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds; while (running) { Display.Refresh(); if (Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds - LastFT > 16) { LastFT = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds; if (Camera.Rotation == 360) Camera.Rotation = 0; Camera.Rotation++; } } } private void PaintDisplay(object sender, PaintEventArgs e) { e.Graphics.PixelOffsetMode = PixelOffsetMode.Half; model.DrawSpriteStack(e.Graphics); } private void ResizeDisplay() { Display.Left = 0; Display.Top = 0; Display.Width = Width; Display.Height = Height - 32; Camera.Width = Width; Camera.Height = Height - 32; } private void ResizeWindow(object sender, EventArgs e) { ResizeDisplay(); } private void KillThreads(object sender, FormClosingEventArgs e) { running = false; } private void FrameTimer(object sender, EventArgs e) { } private void KeyPressEvent(object sender, KeyPressEventArgs e) { } private void KeyDownEvent(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.W) Camera.LocY++; if (e.KeyCode == Keys.S) Camera.LocY--; if (e.KeyCode == Keys.A) Camera.LocX++; if (e.KeyCode == Keys.D) Camera.LocX--; } } }