Example #1
0
//-----------------------------------------------------------------------
bool Window::Update()
{
	SDL_Event event;
	while ( SDL_PollEvent(&event) )
	{
		switch ( event.type )
		{
			// ќбщие событи¤
		case SDL_QUIT:
			SDL_Quit();
			return false;
			// —обыти¤ мыши
		case SDL_MOUSEBUTTONUP:
			eventMouse(GetMouseButton(event.button.button), false, event.button.x, event.button.y);
			break;
		case SDL_MOUSEBUTTONDOWN:
			eventMouse(GetMouseButton(event.button.button), true, event.button.x, event.button.y);
			break;
		case SDL_MOUSEMOTION:
			eventCursor(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel);
			break;
		case SDL_MOUSEWHEEL:
			mouseWheel(event.wheel.x, event.button.x, event.button.y); // TODO: ? может не x?
			break;
			// —обыти¤ клавиатуры
		case SDL_KEYDOWN:
			eventKey((KEYS)(event.key.keysym.sym), L'', true);
			break;
		case SDL_KEYUP:
			eventKey((KEYS)(event.key.keysym.sym), L'', false);
			break;
		}

		// —обыти¤ окна
		if ( event.type == SDL_WINDOWEVENT )
		{
			switch ( event.window.event )
			{
				// событие изменени¤ размера окна
			case SDL_WINDOWEVENT_SIZE_CHANGED:
				if ( m_newWidth != event.window.data1 || m_newHeight != event.window.data2 )
				{
					m_isResize = true;
					m_newWidth = event.window.data1;
					m_newHeight = event.window.data2;
					m_desc.Size.X = m_newWidth;
					m_desc.Size.Y = m_newHeight;
				}
				break;
			}
		}
	}

	return true;
}
Example #2
0
int main (int argc, char *argv[])
{
	int inc=0;
	
	start_time = time(NULL);
	
	GetArguments(argc, argv); /* Get the script filename */
	PrintVersion();  /* Print info */
	InitGFX();       /* Setup SDL  */	
	DisplayTitle();  /* Show the irixbasic titles */
	DisplayReady();  /* Display the ready text */
	
	LoadScript(); 
	
	SDL_Flip(screen);
	ubasic_init(program); /* Setup uBasic  */	
	
	
	/* Start the program when the user is ready */
	PrintTextLine("Click to Run.");
	SDL_Delay(200);
	do
	{
		GetInput();   /* Read the inputs */
	}while (!GetMouseButton());
	
	
	do
	{
		GetInput();   /* Read the inputs */
		ubasic_run(); /* Process a line of code*/
	}while (!ubasic_finished() && !done);
	
	PrintTextLine("");
	PrintTextLine("Click or Press ESC to quit.");
	SDL_Flip(screen);
	
	while(!done && !GetMouseButton()){
		GetInput();
	}
	
	TTF_CloseFont( fntc64 );
	
	return 0;
}