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.
Bookmarks