private void InitializeGame() { // initialize texture bFrame = new Bitmap(pictureBox1.Width, pictureBox1.Height); LoadTexture(textureQuality); // Clear objects lstUFO.Clear(); rmlstUFO.Clear(); lstBullet.Clear(); rmlstBullet.Clear(); // setup objects oTitleLogo = new obj_null((pictureBox1.Width / 2) - (370 / 2), Convert.ToInt32(((pictureBox1.Height / 2) - (230 / 2)) * 0.5), 370, 230); oFloor = new obj_null(bFloor, 0, pictureBox1.Height - floorHeight, pictureBox1.Width, floorHeight); // setup fort object oFort = new obj_fort(); oFort.Height = 75; oFort.Width = 50; oFort.X = (pictureBox1.Width / 2) - (oFort.Width / 2); oFort.Y = pictureBox1.Height - oFort.Height - oFloor.Height; oFort.Image = bFort; // clear game information gameScore = 0; gameover = false; }
public static bool isCollision(obj_null o1, obj_null o2) { if ((o2.X + o2.Width < o1.X) || (o2.X > o1.X + o1.Width) || (o2.Y + o2.Height < o1.Y) || (o2.Y > o1.Y + o1.Height)) { return(false); } return(true); }
public static bool isClick(obj_null o1, int X, int Y) { if (GetAsyncKeyState((int)0x1 & 0x1) == 0) { return(false); } if (X < o1.X || X > o1.X + o1.Width || Y < o1.Y || Y > o1.Y + o1.Height) { return(false); } return(true); }
private void PictureBox1_Resize(object sender, EventArgs e) { if (Environment.TickCount - resize_timestamp > 50) { Gen_Texture_Floor(textureQuality); oFloor = new obj_null(bFloor, 0, pictureBox1.Height - floorHeight, pictureBox1.Width, floorHeight); bFrame = new Bitmap(pictureBox1.Width, pictureBox1.Height); oTitleLogo.X = (pictureBox1.Width / 2) - (370 / 2); oTitleLogo.Y = Convert.ToInt32(((pictureBox1.Height / 2) - (230 / 2)) * 0.5); oFort.Y = pictureBox1.Height - oFort.Height - floorHeight; resize_timestamp = Environment.TickCount; } }