/
misc.pas
68 lines (63 loc) · 2.41 KB
/
misc.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function load_music() : boolean;
begin
if Mix_OpenAudio( MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096 ) < 0 then HALT;
music := Mix_LoadMUS('megadens.ogg');
if music = nil then HALT;
Mix_VolumeMusic( MIX_MAX_VOLUME );
if Mix_PlayMusic( music, -1 ) < 0 then begin Writeln('Playback failed!');
end else Writeln('Playback started.');
load_music:= true;
end;
function distray_x(ray_l,alpha:real): real;
begin
distray_x:=ray_l*cos(alpha*degtorad);
end;
function distray_y(ray_l,alpha:real): real;
begin
distray_y:=ray_l*sin(alpha*degtorad);
end;
procedure SetPlayer(x,y:integer);
begin
pl_x:=map_scale*x; // player positioned in middle of the square !
pl_y:=map_scale*y; // without substract (!) half of the square !! (map_scale DIV 2 = 8)
end;
procedure load_map(mapname:string);
var i,j, k,l: integer;
mapfile: file of smallint;
begin
Assign(mapfile, mapname);
Reset(mapfile);
for i:=0 to max_Anz do begin
for j:=0 to max_Anz do begin
read(mapfile, map[i,j]);
end;
end;
Close(mapfile);
for k:=0 to max_Anz do begin
for l:=0 to max_Anz do begin
if map[k,l]=9 then begin
SetPlayer(k,l);
map[k,l]:=0;
writeln('Player placed at X: ', k, ' Y: ', l);
break;
end;
end;
end;
Writeln('Map loaded successfully!');
end;
procedure GameInit();
begin
if SDL_Init( SDL_INIT_VIDEO or SDL_INIT_AUDIO ) < 0 then begin HALT;
end else writeln ('Initializing SDL... ok.');
window:= SDL_CreateWindow('RejKaster4',64,64,scr_width,scr_height,SDL_WINDOW_SHOWN);
//SDL_CreateWindow('RejKaster4',SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,scr_width,scr_height,SDL_WINDOW_SHOWN);
//new(event); //creating an event
rend:= SDL_CreateRenderer(window,-1,SDL_RENDERER_ACCELERATED);
SDL_ShowCursor(0);
SDL_SetRenderDrawColor(rend, 0,0,0,0);
SDL_RenderClear(rend);
SDL_RenderPresent(rend); //creating and cleaning the window
SDL_WarpMouseInWindow(window, mouswidth, mousheight); //initialize MousePos
rotate:=0; //angle of playerview horizontal
rotatez:=0; //angle of playerview vertical
end;