Results 1 to 9 of 9

Thread: Weird error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Weird error

    Hello friends

    In order to get better at programming, I decided to follow a tutorial called "reconstructing cave story" over at https://github.com/JIghtuse/cavestor...7ea5f85a5e/src, but instead of C++, I'm trying to do it in Pascal.
    After a few hours, I've hit the first roadblock. The code compiles just fine, but when I try to run the program, I alsways get "External: SIGSEGV" and it stops here:
    Code:
    constructor sprite.sprite(filepath:string; sourcex:integer; sourcey:integer; width:integer; height:integer; ren:psdl_renderer);
    begin
        inherited;
        renderer_ := ren;
        texture_ := img_loadtexture(renderer_, pchar(filepath));
        sourcerect_.x := sourcex;
        sourcerect_.y := sourcey;
        sourcerect_.w := width;
        sourcerect_.h := height;
    end;
    This part gets called by
    Code:
    new(sprite_);
        sprite_^.sprite('gfx/MyChar.png', 0, 0, 16, 16, @graphics.getrenderer);
    Code:
    type
        sprite = class
        public
            constructor sprite(filepath:string; sourcex:integer; sourcey:integer; width:integer; height:integer; ren:psdl_renderer);
            destructor sprite();
    
            procedure draw(graphics:graphics; x:integer; y:integer);
    
        private
            renderer_: psdl_renderer;
            texture_: psdl_texture;
            sourcerect_: tsdl_rect;
        end;
    I don't really understand what I'm doing wrong. It would be great if somebody could give it a quick look over.

    Just in case, here is the full code (~200 lines of code in total).
    cave_story.lps http://pastebin.com/3mSDfgrB
    game1.pas http://pastebin.com/bCmKteK2
    graphics1.pas http://pastebin.com/iERSNVqx
    sprite1.pas http://pastebin.com/ZiPvMvCi

    Thanks a lot in advance guys.
    Last edited by much.love; 21-03-2014 at 06:29 PM.

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
  •