Q
question_asker
Guest
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace packman
{
public partial class random_gneration : Form
{
public random_gneration()
{
InitializeComponent();
game_time.Start();
pckman.Start();
}
Random rand = new Random();
int count = 0, y_axis = 0, speed = 8;
bool down, up, left, right;
private void Pckman_Tick(object sender, EventArgs e)
{
if (left)
{
pack_man.Left -= speed;
}
else if (right)
{
pack_man.Left += speed;
}
else if (up)
{
pack_man.Top -= speed;
}
else if (down)
{
pack_man.Top += speed;
}
//what will be condition for detection of collion with image
}
private void key_DOWN(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
up = true;
pack_man.Image = Properties.Resources.ezgif_4_6f0e13cdcf82;
down = left = right = false;
}
if (e.KeyCode == Keys.Down)
{
down = true;
pack_man.Image = Properties.Resources.ezgif_4_3befc8f66dcc;
up = left = right = false;
}
if (e.KeyCode == Keys.Left)
{
left = true;
pack_man.Image = Properties.Resources.ezgif_4_867ed1223b37;
down = up = right = false;
}
if (e.KeyCode == Keys.Right)
{
right = true;
pack_man.Image = Properties.Resources.right;
down = left = up = false;
}
}
private void Game_time_Tick(object sender, EventArgs e)
{
this.CreateGraphics().DrawImage(Properties.Resources.wallblock,
new PointF(rand.Next(20, 600), y_axis));
if (count % (rand.Next(5, 10)) == 0)
{
y_axis = (y_axis + rand.Next(90, 200)) % 600;
}
count++;
if (count == 30)
{
game_time.Stop();
}
}
}
}
please help
Continue reading...
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace packman
{
public partial class random_gneration : Form
{
public random_gneration()
{
InitializeComponent();
game_time.Start();
pckman.Start();
}
Random rand = new Random();
int count = 0, y_axis = 0, speed = 8;
bool down, up, left, right;
private void Pckman_Tick(object sender, EventArgs e)
{
if (left)
{
pack_man.Left -= speed;
}
else if (right)
{
pack_man.Left += speed;
}
else if (up)
{
pack_man.Top -= speed;
}
else if (down)
{
pack_man.Top += speed;
}
//what will be condition for detection of collion with image
}
private void key_DOWN(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
up = true;
pack_man.Image = Properties.Resources.ezgif_4_6f0e13cdcf82;
down = left = right = false;
}
if (e.KeyCode == Keys.Down)
{
down = true;
pack_man.Image = Properties.Resources.ezgif_4_3befc8f66dcc;
up = left = right = false;
}
if (e.KeyCode == Keys.Left)
{
left = true;
pack_man.Image = Properties.Resources.ezgif_4_867ed1223b37;
down = up = right = false;
}
if (e.KeyCode == Keys.Right)
{
right = true;
pack_man.Image = Properties.Resources.right;
down = left = up = false;
}
}
private void Game_time_Tick(object sender, EventArgs e)
{
this.CreateGraphics().DrawImage(Properties.Resources.wallblock,
new PointF(rand.Next(20, 600), y_axis));
if (count % (rand.Next(5, 10)) == 0)
{
y_axis = (y_axis + rand.Next(90, 200)) % 600;
}
count++;
if (count == 30)
{
game_time.Stop();
}
}
}
}
please help
Continue reading...