   Virtual Arena / Virtual Creatures problems
  Hello there.I'm trying to write a program that I will eventually use to create a 2D arena where little creatures (pixels basically) will wonder around and do stuff. The first thing I want to do is create one of those termite simulations, where the 'termite' pixels move around randomly, pick up pieces of dirt (i.e brown pixels) and drop them to demonstrate emergent behavior.I know all the theory and how I'm going to implement such a simulation, but I'm having difficulty with actually making the virtual arena itself.http://img.villagephotos.com/p/2003-11/474332/screenie.JPGAbove is a screenshot of what I have at the moment. That's the idea, I have a dialog window with a frame inside it plus a bunch of controls (i.e where you can specify number of creatures, speed of simulation etc). The main problem I have is with getting the 'arena' frame to update.At the moment, all the code for the movement and drawing of the 'creature' is called from void program::OnPaint(). Example :void CTermitesDlg::OnPaint() {CPaintDC dc(this); // device context for paintingCDC *pDC=m_virtualWorld.GetDC();CRect picrect;m_virtualWorld.GetClientRect(&picrect);   DrawXYAxis(pDC,&picrect); //this is where the creature    // location is changed and drawn on the dc.CDialog::OnPaint();}    Now this is obviously wrong. The creature only moves to its new location (a random step is added to the current coordinate) when I minimise/maximise the frame. I.e the frame will only refresh (and therefore the contents of OnPaint ran) when I re-display the window.My question is, how should I structure this program so that the creature(s) move(s) every cycle, and the movements are shown in the dc? I'm using MFC at the moment (its the only way I know how to create a program), so where can I put the AI code so that the creature moves? This function needs to be called every cycle as I have said, but I can't see where in my program I could place this function so that it would run all the time (as oposed to the current program, where a new step is only taken when I change the program's status (i.e minimize/maximise).I know this is pretty basic stuff, but I have very little experince with Win32 at this level.Any help would be great,SFA.[edited by - SFA on February 17, 2004 11:22:07 AM][edited by - SFA on February 17, 2004 11:22:43 AM][edited by - SFA on February 17, 2004 11:23:52 AM][edited by - SFA on February 17, 2004 11:24:13 AM][edited by - SFA on February 17, 2004 11:24:29 AM][edited by - SFA on February 17, 2004 11:24:47 AM][edited by - SFA on February 17, 2004 11:25:07 AM][edited by - SFA on February 17, 2004 11:25:38 AM]
  Apologies for all the edits! Can''t make the link clickable! 