Results 1 to 5 of 5

Thread: Display PNG's in different places

  1. #1

    Display PNG's in different places

    OK. well, simply put, I am making a very basic game, called Tower Invasion, which is a Tower Defense look-alike. I have currently made some graphics, and I'm trying to display the backgrounds and some roads. However, I can't seem to make the program compile unless the sdl_blitsurface(road_vertical,nil,screen,nil); 2nd and 4rth parameters are 'nil'. Anything else, and it won't compile. I'm using Free Pascal, just plain old Free Pascal, no delphi, etc etc. Jedi-SDL is setup properly, and the graphic is working fine...
    This is a picture of what it looks like when run:
    http://i209.photobucket.com/albums/b...nningstage.png

    Code:
    Program TowerInvasion;
    uses sdl, sdl_image, crt;
    const
    
      //version and author info
      appver = 0;
      appauthor = 'DarknessX';
      appdate = 'Aug 12, 07';
    
      grass = 'C:\Projects\Tower Invasion\gfx\grass.png';
      road_vert = 'C:\Projects\Tower Invasion\gfx\road1_vertical.png';
    
      //screen info
      resx = 900; //X axis resolution... Width of screen.
      resy = 900; //Y axis resolution... height of screen.
    
    var
    
      debugmode : boolean; //This is a switch for several things, including error
      //reporting. This switch will force error reporting to save to a file,
      //instead of writing it to the screen.
    
      f : text; //This is for any file writing that may occur.
    
      //screens
      screen : pSDL_Surface; //the actual screen
      background : pSDL_Surface; //forest background
    
      road_vertical : pSDL_Surface;  //upward path, no ends.
      road_horizontal : pSDL_Surface; //leftward path, no ends.
    
      road_lefturn : pSDL_Surface; //going upward road turns left
      road_rigturn : pSDL_Surface; //going upward road turns right
      road_dlefturn : pSDL_Surface; //going downward road turns left
      road_frigturn : pSDL_Surface; //going downward road turns right
    
    
    Procedure ReportError(error: integer; writefile: boolean);
    begin
    .....
    end;
    
    Procedure Initiate;
    begin
      debugmode := true;
      SDL_Init(SDL_Init_Video);
      screen := SDL_SetVideoMode(resx,resy,32,SDL_SWSURFACE);
      if screen = nil then ReportError(1,debugmode);
    end;
    
    
    
    Procedure Quit;
    begin
      SDL_FreeSurface(background);
      SDL_FreeSurface(screen);
      SDL_Quit;
    end;
    
    begin
      Initiate;
      repeat
        background := IMG_Load(grass);
        if background = nil then ReportError(1,debugmode);
        road_vertical := IMG_Load(road_vert);
        if road_vertical = nil then ReportError(1,debugmode);
        sdl_blitsurface(background,nil,screen,nil);
        sdl_blitsurface(road_vertical,nil,screen,nil);
        sdl_flip(screen);
      until debugmode = false;
        readln;
      Quit;
    end.
    --MagicRPG--

  2. #2

    Display PNG's in different places

    The 4 parameter specify where the image will be draw so specify it
    Code:
    procedure ...
    var
     dst: TSDL_Rect;
    begin
    dst.x :=
    dst.y :=
    dst.w :=
    dst.h :=
    sdl_blitsurface(road_vertical,nil,screen,@dst);
    end;
    use @dst on 4 parameter
    From brazil (:

    Pascal pownz!

  3. #3

    Display PNG's in different places

    Thanks, arthurprs! Thats exactly what I needed So simple. I couldn't figure out what I needed to do after 2 hours of fiddling and I got a bit frustrated so I figured to ask on here
    --MagicRPG--

  4. #4

    Display PNG's in different places

    Quote Originally Posted by DarknessX
    Thanks, arthurprs! Thats exactly what I needed So simple. I couldn't figure out what I needed to do after 2 hours of fiddling and I got a bit frustrated so I figured to ask on here
    Post againt if you need ^^
    From brazil (:

    Pascal pownz!

  5. #5

    Display PNG's in different places

    Already did lol
    --MagicRPG--

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •