OpenGL game questions

Page 1 of 1

1 Replies - 385 Views - Last Post: 29 November 2011 - 07:37 AM Rate Topic: -----

#1 JEdN   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 29-November 11

OpenGL game questions

Posted 29 November 2011 - 06:55 AM

I have to create a game in OpenGL with C# for some coursework and I hope someone can help me. Not too much as i'm sure you'll agree I do need to learn not just copy.

The game is basically a pie in the centre of the screen and bugs (which you have to squash) attacking the pie.

I have two current problems:

the first is that I have managed to create a bug texture to load randomly and move but I cannot get more than to appear randomly on the screen. only on top of each other. Here is what I have done wrong.

public World()
{
for (float numBugs = 0; numBugs < 2; ++numBugs)
{
// Creates a random integer, either -2,-1,0,1,2
m_BugPosition.X = rand.Next(-2, 2);
m_BugPosition.Y = rand.Next(-2, 2);

Bug bug = new Bug(
new Vector2d(m_BugPosition.X, m_BugPosition.Y),
new Vector2d(0.0f, 0.0f));
m_Bugs.Add(bug);
}
}

So as you can see i am creating a random for now (i will be generating a double once I've sorted it) and a new bug should appear in one of those co-ordinates.


The next problem I have is making the bug actually disappear when I click on it with my animated mallet.

Here is my code;

if (pButtons == MouseButtons.Left)
{
mouseState = MouseState.MouseClicked;

foreach (Bug bug in m_Bugs)
{
if (( m_Point1.X < m_BugPosition.X + 0.2f)
&& (m_Point1.X > m_BugPosition.X - 0.2f)
&& (m_Point1.Y < m_BugPosition.Y + 0.2f)
&& (m_Point1.Y > m_BugPosition.Y - 0.2f))

{
Bug.Remove();
}
}
}
So here I am clicking with my left mouse the state changes to mouseclick so the texture changes and within that arrear it should detect the bug and remove it

Hope someone can help

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: OpenGL game questions

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15782
  • View blog
  • Posts: 63,261
  • Joined: 12-June 08

Re: OpenGL game questions

Posted 29 November 2011 - 07:37 AM

Please do not open duplicate threads - thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1