OpenGL and C#

Associate
Joined
26 Jan 2009
Posts
286
Location
Hull
Hello all could you please help me. I am creating a game using OpenGL and C#. It's called "Protect The Pie" so basically its a pie in the middle and flies are going to try eat it. I've drawn(displayed) the background, pie and fly. I do I go about moving the fly?

Much appreciated,
Luke
 
I got another question if you guys don't mind. I'm trying to get this program to work. basically its balls moving around the screen, but i can't seem to get it to work. I know its to do with my update method but i'm not to sure how about to go and correct this. here is my code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenGL;
using _08240FormsLibrary;

namespace LearnVector2d
{
class World
{

private Circle m_Circle = new Circle(new Vector2d(0.0f, 0.0f), new Vector2d(1.0f, 0.0f), 1.0f);
private List<Circle> m_Circles = new List<Circle>();

private HiResTimer m_Timer = new HiResTimer();

public void Draw()
{

GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // clear some buffers //to give a fresh scene
GL.glLoadIdentity(); // Load Identity Matrix
GL.glTranslatef(0.0f, 0.0f, -3.0f); // Translate 3 Units Into The Screen
foreach(Circle circle in m_Circles)
{
circle.Draw();
}
GL.glFlush(); // Flush commands to graphics card
}

public void Update()
{
float timeStep = m_Timer.Seconds;
m_Circle.Update(timeStep);


}

public World()
{
for (float i = 0, yPos = -1, xVel = 0.4f; i < 10; ++i, yPos += 0.2f, xVel += 0.2f)
{
Circle circle = new Circle(new Vector2d(0.0f, yPos), new Vector2d(xVel, 0.0f), 0.1f); m_Circles.Add(circle);
}
}
}
}
 
I have no idea in what context that code is working.

Is their a loop?

Is the velocity vector being added to the position vector on each iteration of the loop?

and so on...

There just needs to be a loop that:

Draws
then
Updates position vectors by adding on velocity vectors


What's actually going on?
 
Last edited:
Back
Top Bottom