TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aaron Raine
NA
2
2.2k
make my goblin appear and move after 5 seconds
Apr 25 2014 5:19 PM
using System;
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
if ((goblin.Left + goblin.Width) >= (Form1.ActiveForm.Width - step))
horiz = -1;
// if goblin has hit the LHS edge, if so change direction right
if (goblin.Left <= step)
horiz = 1;
// if goblin has hit the bottom edge, if so change direction upwards
if ((goblin.Top + goblin.Height) >= (Form1.ActiveForm.Height - step))
vert = -1;
// if goblin has hit the top edge, if so change direction downwards
if (goblin.Top < step)
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
horiz = 1; //start going right
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.
Reply
Answers (
1
)
make a picture appear within 5 second in Microsoft Visual C#
About to make calculator