Results 1 to 2 of 2

Thread: C# OpenGL moving Balls

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    1

    C# OpenGL moving Balls

    Hello all please can I have your help. 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);
    }
    }
    }
    }

    Much Appreciated

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: C# OpenGL moving Balls

    Please use [ code]/[ /code] (without space after '[') around code snippets to make them more readable.

    You are not saying what exactly the problem is, i.e. what is happening vs. what you'd want to happen. Also, all the interesting stuff of the update presumably happens in Circle::Update(float time), but you haven't posted that code, please do.

    The Forum Posting Guidelines have additional hints how to make posts in a way that they can be easily answered.

Similar Threads

  1. Balls not getting generated in proper cordinates
    By centurion in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-27-2011, 01:39 AM
  2. !!! PANIC !!! Rolling balls on plane!
    By eisebs in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-13-2003, 02:20 AM
  3. How to rotate the pool while the balls going?
    By Dong Ke in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-24-2001, 05:18 PM
  4. rolling two balls + reflection
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-10-2001, 07:05 AM
  5. Hairy balls
    By JamesP in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 01-16-2001, 03:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean