Click here to Skip to main content
15,887,273 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: boost:asio Pin
Richard MacCutchan22-Apr-11 22:42
mveRichard MacCutchan22-Apr-11 22:42 
AnswerRe: boost:asio Pin
Albert Holguin28-Apr-11 15:01
professionalAlbert Holguin28-Apr-11 15:01 
QuestionCursor, converting code from vb.net to c++ Pin
Andreoli Carlo21-Apr-11 2:48
professionalAndreoli Carlo21-Apr-11 2:48 
AnswerRe: Cursor, converting code from vb.net to c++ Pin
Andreoli Carlo21-Apr-11 3:13
professionalAndreoli Carlo21-Apr-11 3:13 
QuestionDeployment of Managed C++ application Pin
pix_programmer14-Apr-11 20:55
pix_programmer14-Apr-11 20:55 
Questioncreating new instance using com smart pointer fails Pin
Dhadhan13-Apr-11 18:18
Dhadhan13-Apr-11 18:18 
AnswerRe: creating new instance using com smart pointer fails Repost Pin
Richard MacCutchan13-Apr-11 22:20
mveRichard MacCutchan13-Apr-11 22:20 
QuestionSounds in .Net. How? Pin
Cyclone_S2-Apr-11 13:26
Cyclone_S2-Apr-11 13:26 
AnswerRe: Sounds in .Net. How? Pin
Richard Andrew x642-Apr-11 16:02
professionalRichard Andrew x642-Apr-11 16:02 
QuestionAny update on Intellisense for C++/CLI in VS2010 Pin
Ger Hayden1-Apr-11 8:44
Ger Hayden1-Apr-11 8:44 
AnswerRe: Any update on Intellisense for C++/CLI in VS2010 Pin
John Schroedl2-Apr-11 13:46
professionalJohn Schroedl2-Apr-11 13:46 
GeneralRe: Any update on Intellisense for C++/CLI in VS2010 Pin
T21026-Apr-11 17:29
T21026-Apr-11 17:29 
QuestionAnimating a snake (aka Snafu) [modified] Pin
Cyclone_S25-Mar-11 14:20
Cyclone_S25-Mar-11 14:20 
AnswerRe: Animating a snake (aka Snafu) Pin
Richard Andrew x6425-Mar-11 14:40
professionalRichard Andrew x6425-Mar-11 14:40 
GeneralRe: Animating a snake (aka Snafu) Pin
Cyclone_S25-Mar-11 14:54
Cyclone_S25-Mar-11 14:54 
GeneralRe: Animating a snake (aka Snafu) Pin
Richard Andrew x6425-Mar-11 14:57
professionalRichard Andrew x6425-Mar-11 14:57 
GeneralRe: Animating a snake (aka Snafu) Pin
Cyclone_S26-Mar-11 13:09
Cyclone_S26-Mar-11 13:09 
Hi,

So far I created a Snake_Part class. When the Form1 class is first created is calls the Make_Snake Function which creates 4 Snake_Part objects which are added to the list.

How do I move the last panel to the front. I'm using a list to store the Snake_Part instances. A timer will be used to move the snake. I need to some how find the last/first elements in the list and then move them acordingly.

#include "stdafx.h"
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Collections::Generic; // Required to make lists.

public ref class Snake_Part
{
	public:
			Panel^ panel;

			Snake_Part( Form ^ form ) // Class Constructor.
			{ 
				panel = gcnew Panel();
				panel->BackColor = Color::Blue;
				panel->Width = 20; panel->Height = 20;
				form->Controls->Add(panel);
			}
};

public ref class Form1 : public Form 
{
	public:
			List<Snake_Part^>^ Parts; // A list that contains the snake parts.
			int length; // The length of the  snake.
			Timer^ Timer1; // The timer that will move the snake;
			//Panel^ p;
			Form1() // Class constructor.
			{	
				Parts = gcnew List<Snake_Part^>();
				Timer1 = gcnew Timer();
				Timer1->Interval = 2000;
				Timer1->Start();
				Timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
				Make_Snake();
			}
			
			void Make_Snake()
			{
				double clr = 255;
				double dclr = 128 / 2;

				for(int I = 0; I <= 3; I++)
				{
					Snake_Part^ p = gcnew Snake_Part(this);
					p->panel->BackColor = Color::FromArgb(0,0,clr);
					Parts->Add(p);
					clr -= dclr;
				}

				for each (Snake_Part^ p in Parts)
				{
					length += p->panel->Width + 2;
					p->panel->Left = length;
				}	
			}

			void move_snake()
			{
					
			}

			System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) // A timer that will move the snake;
			{
				move_snake();
				
			}
};

[STAThread]
int main()
{
    Application::Run(gcnew Form1());
}


Thanks
GeneralRe: Animating a snake (aka Snafu) Pin
Richard Andrew x6426-Mar-11 13:50
professionalRichard Andrew x6426-Mar-11 13:50 
GeneralRe: Animating a snake (aka Snafu) Pin
Cyclone_S27-Mar-11 13:27
Cyclone_S27-Mar-11 13:27 
GeneralRe: Animating a snake (aka Snafu) Pin
Richard Andrew x6427-Mar-11 14:12
professionalRichard Andrew x6427-Mar-11 14:12 
GeneralRe: Animating a snake (aka Snafu) Pin
Cyclone_S27-Mar-11 14:25
Cyclone_S27-Mar-11 14:25 
GeneralRe: Animating a snake (aka Snafu) Pin
Richard Andrew x6427-Mar-11 15:24
professionalRichard Andrew x6427-Mar-11 15:24 
GeneralRe: Animating a snake (aka Snafu) Pin
Cyclone_S28-Mar-11 13:21
Cyclone_S28-Mar-11 13:21 
GeneralRe: Animating a snake (aka Snafu) Pin
Cyclone_S30-Mar-11 13:22
Cyclone_S30-Mar-11 13:22 
GeneralRe: Animating a snake (aka Snafu) Pin
Richard Andrew x6430-Mar-11 14:41
professionalRichard Andrew x6430-Mar-11 14:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.