Пример #1
0
void
XDLink::Send
	(
	const JCharacter* text
	)
{
	if (itsLink != NULL)
		{
		if (ProgramIsRunning())
			{
			StopProgram();
			}

		JString arg = " -i not_command";

		JString s = text;
		JIndex i;
		if (s.LocateSubstring("@i", &i))
			{
			s.ReplaceSubstring(i, i+1, arg);
			}
		else
			{
			s += arg;
			}

		SendRaw(s);
		}
}
Пример #2
0
int main(int argc, char *argv[])
{
  if(!InitGame())
    {
      printf("%s\n", SDL_GetError());
      FreeGame();   //If InitGame failed, kill the program
      return 0;
    }

  while(ProgramIsRunning())
    {
      long int oldTime = SDL_GetTicks();  //We will use this later to see how long it took to update the frame
      SDL_FillRect(Backbuffer, NULL, 0);  //Clear the screen
      RunGame();                          //Update the game
      DrawGame();                         //Draw the screen

      int frameTime = SDL_GetTicks() - oldTime;

      if(frameTime < FRAME_DELAY)                 //Dont delay if we dont need to
	SDL_Delay(FRAME_DELAY - frameTime);     //Delay

      //In SDL 2, SDL_UpdateWindowSurface replaces SDL_Flip
      SDL_UpdateWindowSurface(Window);            //Flip the screen
    }

  FreeGame();     //Gracefully release SDL and its resources.

  return 0;
}
Пример #3
0
int main(int argc, char* args[])
{
    if(SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        //This is a nice alternative to printf in SDL 2
        SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SDL", "SDL failed to initialize!", NULL);
        SDL_Quit();
        return 0;
    }

    //In SDL 2, SDL_SetVideoMode has been removed, we now create windows using SDL_CreateWindow to create windows
    Window = SDL_CreateWindow("I can talk!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);

    //SDL_GetWindowSurface gets the backbuffer of the window we created with SDL_CreateWindow
    Backbuffer = SDL_GetWindowSurface(Window);

    if(!LoadFiles())
    {
      SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SDL", SDL_GetError(), NULL);

        //SDL_DestroyWindow destroys a window we created with SDL_CreateWindow
        SDL_DestroyWindow(Window);
        FreeFiles();
        SDL_Quit();

        return 0;
    }

    while(ProgramIsRunning())
    {
        DrawImage(Background,Backbuffer, 0, 0);
        DrawRasterText(FontImage, Backbuffer, "All Systems Go!" , 100, 100, charSize);
        DrawRasterText(FontImage, Backbuffer, "Drawing Fonts is Fun!", 100, 116, charSize);

        SDL_Delay(20);

        //In SDL 2, SDL_UpdateWindowSurface replaces SDL_Flip
        SDL_UpdateWindowSurface(Window);
    }

    FreeFiles();

    //SDL_DestroyWindow destroys a window we created with SDL_CreateWindow
    SDL_DestroyWindow(Window);
    SDL_Quit();

    return 0;
}
Пример #4
0
int main(int argc, char* args[])
{
    if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        printf("Failed to initialize SDL!\n");
        return 0;
    }

    Backbuffer = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);

    SDL_WM_SetCaption("Green is my pepper", NULL);

    if(!LoadFiles())
    {
        printf("Failed to load all files!\n");
        FreeFiles();
        SDL_Quit();

        return 0;
    }

    while(ProgramIsRunning())
    {
        //Update's the sprites frame
        FrameCounter++;

        if(FrameCounter > FrameDelay)
        {
            FrameCounter = 0;
            SpriteFrame++;
        }

        if(SpriteFrame > MaxSpriteFrame)
            SpriteFrame = 0;

        //Update's Background scrolling
        //BackgroundX-=6;
        //if(BackgroundX <= -800)
        //    BackgroundX = 0;

        //freeX += 3;
        //if(freeX >= 800)
        //	freeX = 0;

        // I ought to write a macro for this
        switch(direction){
        case NE:
        	// it's > N and E border
        	if(freeX >= 800-32 && freeY >= 600+32){
        		direction = SW;
        	}
        	// it's > E border
        	else if (freeX >= 800-32){
        		direction = NW;
        	}
        	// it's > N border
        	else if (freeY >= 600+32){
        		direction = SE;
        	}
        	// continue normally
        	else{
        		freeX+=INC;
        		freeY+=INC;
                //printf("NE\n");
        	}
        	break;
        case NW:
        	// it's greater than N and W border
        	if(freeX <= 0 && freeY >= 600+32){
        		direction = SE;
        	}
        	// it's > W border
        	else if (freeX <= 0){
        		direction = NE;
        	}
        	// it's > N border
        	else if (freeY >= 600 + 32){
        		direction = SW;
        	}
        	// continue normally
        	else{
        		freeX-=INC;
        		freeY+=INC;
                //printf("NW\n");
        	}
        	break;
        case SE:
        	// it's greater than S and E border
        	if(freeX >= 800-32 && freeY <= 0){
        		direction = NW;
        	}
        	// it's > E border
        	else if (freeX >= 800-32){
        		direction = SW;
        	}
        	// it's > S border
        	else if (freeY <= 0+32){
        		direction = NE;
        	}
        	else{
        		freeX+=INC;
        		freeY-=INC;
                //printf("SE\n");
        	}
        	break;
        case SW:
            // it's greater than S and W border
            if(freeX <= 0 && freeY <= 0){
                direction = NE;
            }
            // it's > W border
            else if (freeX <= 0){
                direction = SE;
            }
            // it's > S border
            else if (freeY <= 0+32){
                direction = NW;
            }
            // continue normally
            else{
                freeX-=INC;
                freeY-=INC;
                //printf("SW\n");
            }
            break;
        }



        //Render the scene
        DrawImage(Background,Backbuffer, BackgroundX, 0);
        DrawImage(Background,Backbuffer, BackgroundX+800, 0);
        DrawImage(SpriteImage, Backbuffer, freeX,600-freeY);

        SDL_Delay(20);
        SDL_Flip(Backbuffer);
    }

    FreeFiles();

    SDL_Quit();

    return 0;
}