using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Bounce
{
public partial class Form1 : Form
{
int horiz, vert, step;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick_1(object sender, EventArgs e)
{
//image is moved at each interval of the timer
goblin.Left = goblin.Left + (horiz * step);
goblin.Top = goblin.Top + (vert * step);
// if goblin has hit the RHS edge, if so change direction left
horiz = -1;
// if goblin has hit the LHS edge, if so change direction right
horiz = 1;
// if goblin has hit the bottom edge, if so change direction upwards
vert = -1;
// if goblin has hit the top edge, if so change direction downwards
vert = 1;
}
private void Form1_Load_1(object sender, EventArgs e)
{
//Soon as the forms loads activate the goblin to start moving
//set the intial direction
vert = 1; //start going down
step = 5;
timer1.Enabled = true;
}
}
}
Please someone tell me how i would get this goblin to appear after 5 seconds and move around the screen instead of it already being there and already bouncing around the screen.
FroglegPosted Apr 26, 2014, 4:19 AM
Create a bool goblinVisible and when timer times out, change it to true
In the paint event
if(goblinVisible )
{
drawgoblin
}