Compare commits
5 Commits
firstCommi
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c8838aa450 | |||
| 896a61ed0d | |||
| c7a7e604f1 | |||
| cdfb966fc3 | |||
| 18e45526b8 |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.vscode/*
|
||||||
|
.DS_Store
|
||||||
|
thumbs.db
|
||||||
|
bin/*
|
||||||
151
ASTEROID.PAS
151
ASTEROID.PAS
@@ -1,151 +0,0 @@
|
|||||||
uses crt,keyboard;
|
|
||||||
|
|
||||||
const
|
|
||||||
marge_dalt=10;
|
|
||||||
marge_baix=192;
|
|
||||||
marge_esq=7;
|
|
||||||
marge_dret=312;
|
|
||||||
|
|
||||||
type
|
|
||||||
ipunt=RECORD r,angle:real; END;
|
|
||||||
punt=RECORD x,y:integer; END;
|
|
||||||
triangle=RECORD p1,p2,p3:ipunt;
|
|
||||||
centre:punt;
|
|
||||||
angle:real;
|
|
||||||
velocitat:real;
|
|
||||||
END;
|
|
||||||
|
|
||||||
procedure MCGA;
|
|
||||||
begin
|
|
||||||
asm
|
|
||||||
mov ax,0013h
|
|
||||||
int 10h
|
|
||||||
end;
|
|
||||||
directvideo:= false;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure Text;
|
|
||||||
begin
|
|
||||||
asm
|
|
||||||
mov ax,0003h
|
|
||||||
int 10h
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure WaitRetrace; assembler;
|
|
||||||
label
|
|
||||||
l1,l2;
|
|
||||||
|
|
||||||
asm
|
|
||||||
mov dx,3DAh
|
|
||||||
|
|
||||||
l1:
|
|
||||||
in al,dx
|
|
||||||
and al,08h
|
|
||||||
jnz l1
|
|
||||||
|
|
||||||
l2:
|
|
||||||
in al,dx
|
|
||||||
and al,08h
|
|
||||||
jz l2
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure posa(x,y:word;color:byte);
|
|
||||||
begin
|
|
||||||
mem[$A000:y*320+x]:=color;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure linea(x1,y1,x2,y2,color:word);
|
|
||||||
|
|
||||||
function sign(x:integer):integer; {like sgn(x) in basic}
|
|
||||||
begin if x<0 then sign:=-1 else if x>0 then sign:=1 else sign:=0 end;
|
|
||||||
|
|
||||||
var
|
|
||||||
x,y,count,xs,ys,xm,ym:integer;
|
|
||||||
begin
|
|
||||||
x:=x1;y:=y1;
|
|
||||||
|
|
||||||
xs:=x2-x1; ys:=y2-y1;
|
|
||||||
|
|
||||||
xm:=sign(xs); ym:=sign(ys);
|
|
||||||
xs:=abs(xs); ys:=abs(ys);
|
|
||||||
|
|
||||||
posa(x,y,color);
|
|
||||||
|
|
||||||
if xs > ys
|
|
||||||
then begin {flat line <45 deg}
|
|
||||||
count:=-(xs div 2);
|
|
||||||
while (x <> x2 ) do begin
|
|
||||||
count:=count+ys;
|
|
||||||
x:=x+xm;
|
|
||||||
if count>0 then begin
|
|
||||||
y:=y+ym;
|
|
||||||
count:=count-xs;
|
|
||||||
end;
|
|
||||||
posa(x,y,color);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else begin {steep line >=45 deg}
|
|
||||||
count:=-(ys div 2);
|
|
||||||
while (y <> y2 ) do begin
|
|
||||||
count:=count+xs;
|
|
||||||
y:=y+ym;
|
|
||||||
if count>0 then begin
|
|
||||||
x:=x+xm;
|
|
||||||
count:=count-ys;
|
|
||||||
end;
|
|
||||||
posa(x,y,color);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure rota_tri(tri:triangle;angul,velocitat:real;color:byte);
|
|
||||||
var x1,x2,x3,y1,y2,y3:word;
|
|
||||||
begin
|
|
||||||
x1:=round((tri.p1.r+velocitat/2)*cos(tri.p1.angle+angul))+tri.centre.x;
|
|
||||||
x2:=round((tri.p2.r+velocitat/2)*cos(tri.p2.angle+angul+velocitat/5))+tri.centre.x;
|
|
||||||
x3:=round((tri.p3.r+velocitat/2)*cos(tri.p3.angle+angul-velocitat/5))+tri.centre.x;
|
|
||||||
y1:=round((tri.p1.r+velocitat/2)*sin(tri.p1.angle+angul))+tri.centre.y;
|
|
||||||
y2:=round((tri.p2.r+velocitat/2)*sin(tri.p2.angle+angul+velocitat/5))+tri.centre.y;
|
|
||||||
y3:=round((tri.p3.r+velocitat/2)*sin(tri.p3.angle+angul-velocitat/5))+tri.centre.y;
|
|
||||||
linea(x1,y1,x2,y2,color);
|
|
||||||
linea(x1,y1,x3,y3,color);
|
|
||||||
linea(x3,y3,x2,y2,color);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
var nau:triangle;
|
|
||||||
ang:real;
|
|
||||||
ch:char;
|
|
||||||
Dx,Dy:word;
|
|
||||||
|
|
||||||
begin
|
|
||||||
nau.p1.r:=6;nau.p1.angle:=3*pi/2;
|
|
||||||
nau.p2.r:=6;nau.p2.angle:=pi/4;
|
|
||||||
nau.p3.r:=6;nau.p3.angle:=(3*pi)/4;
|
|
||||||
nau.angle:=0;
|
|
||||||
nau.centre.x:=160;nau.centre.y:=100;
|
|
||||||
instalarkb;
|
|
||||||
mcga;
|
|
||||||
repeat
|
|
||||||
waitretrace;
|
|
||||||
rota_tri(nau,nau.angle,nau.velocitat,0);
|
|
||||||
|
|
||||||
if teclapuls(KEYarrowright) then nau.angle:=nau.angle+0.157079632;
|
|
||||||
if teclapuls(KEYarrowleft) then nau.angle:=nau.angle-0.157079632;
|
|
||||||
if teclapuls(KEYarrowup) then begin
|
|
||||||
if nau.velocitat<3 then nau.velocitat:=nau.velocitat+0.1;
|
|
||||||
end;
|
|
||||||
Dy:=round(nau.velocitat*sin(nau.angle-pi/2))+nau.centre.y;
|
|
||||||
Dx:=round(nau.velocitat*cos(nau.angle-pi/2))+nau.centre.x;
|
|
||||||
if (dy>marge_dalt) and (dy<marge_baix) then
|
|
||||||
nau.centre.y:=Dy;
|
|
||||||
if (dx>marge_esq) and (dx<marge_dret) then
|
|
||||||
nau.centre.x:=Dx;
|
|
||||||
if (nau.velocitat>0.05) then nau.velocitat:=nau.velocitat-0.05;
|
|
||||||
rota_tri(nau,nau.angle,nau.velocitat,2);
|
|
||||||
until teclapuls(keyesc);
|
|
||||||
desinstalarkb;
|
|
||||||
text;
|
|
||||||
end.
|
|
||||||
275
KEYBOARD.PAS
275
KEYBOARD.PAS
@@ -1,275 +0,0 @@
|
|||||||
{
|
|
||||||
-----------------------------------------------------
|
|
||||||
File: Keyboard.Pas
|
|
||||||
By: Ronny Wester, ronny@rat.se
|
|
||||||
|
|
||||||
Unit to check up/down status of individual key flags.
|
|
||||||
Written from code I got off rec.games.programmer.
|
|
||||||
Sorry, I lost the name of the poster.
|
|
||||||
As most of this code is scancode-dependent some keys
|
|
||||||
may not be where they "should" on your keyboard.
|
|
||||||
-----------------------------------------------------
|
|
||||||
}
|
|
||||||
unit Keyboard;
|
|
||||||
|
|
||||||
|
|
||||||
interface
|
|
||||||
|
|
||||||
uses Dos;
|
|
||||||
|
|
||||||
|
|
||||||
const
|
|
||||||
|
|
||||||
keySysReq = $54;
|
|
||||||
keyCapsLock = $3A;
|
|
||||||
keyNumLock = $45;
|
|
||||||
keyScrollLock = $46;
|
|
||||||
keyLeftCtrl = $1D;
|
|
||||||
keyLeftAlt = $38;
|
|
||||||
keyLeftShift = $2A;
|
|
||||||
keyRightCtrl = $9D;
|
|
||||||
keyAltGr = $B8;
|
|
||||||
keyRightShift = $36;
|
|
||||||
keyEsc = $01;
|
|
||||||
keyBackspace = $0E;
|
|
||||||
keyEnter = $1C;
|
|
||||||
keySpace = $39;
|
|
||||||
keyTab = $0F;
|
|
||||||
keyF1 = $3B;
|
|
||||||
keyF2 = $3C;
|
|
||||||
keyF3 = $3D;
|
|
||||||
keyF4 = $3E;
|
|
||||||
keyF5 = $3F;
|
|
||||||
keyF6 = $40;
|
|
||||||
keyF7 = $41;
|
|
||||||
keyF8 = $42;
|
|
||||||
keyF9 = $43;
|
|
||||||
keyF10 = $44;
|
|
||||||
keyF11 = $57;
|
|
||||||
keyF12 = $58;
|
|
||||||
keyA = $1E;
|
|
||||||
keyB = $30;
|
|
||||||
keyC = $2E;
|
|
||||||
keyD = $20;
|
|
||||||
keyE = $12;
|
|
||||||
keyF = $21;
|
|
||||||
keyG = $22;
|
|
||||||
keyH = $23;
|
|
||||||
keyI = $17;
|
|
||||||
keyJ = $24;
|
|
||||||
keyK = $25;
|
|
||||||
keyL = $26;
|
|
||||||
keyM = $32;
|
|
||||||
keyN = $31;
|
|
||||||
keyO = $18;
|
|
||||||
keyP = $19;
|
|
||||||
keyQ = $10;
|
|
||||||
keyR = $13;
|
|
||||||
keyS = $1F;
|
|
||||||
keyT = $14;
|
|
||||||
keyU = $16;
|
|
||||||
keyV = $2F;
|
|
||||||
keyW = $11;
|
|
||||||
keyX = $2D;
|
|
||||||
keyY = $15;
|
|
||||||
keyZ = $2C;
|
|
||||||
key1 = $02;
|
|
||||||
key2 = $03;
|
|
||||||
key3 = $04;
|
|
||||||
key4 = $05;
|
|
||||||
key5 = $06;
|
|
||||||
key6 = $07;
|
|
||||||
key7 = $08;
|
|
||||||
key8 = $09;
|
|
||||||
key9 = $0A;
|
|
||||||
key0 = $0B;
|
|
||||||
keyMinus = $0C;
|
|
||||||
keyEqual = $0D;
|
|
||||||
keyLBracket = $1A;
|
|
||||||
keyRBracket = $1B;
|
|
||||||
keySemicolon = $27;
|
|
||||||
keyTick = $28;
|
|
||||||
keyApostrophe = $29;
|
|
||||||
keyBackslash = $2B;
|
|
||||||
keyComma = $33;
|
|
||||||
keyPeriod = $34;
|
|
||||||
keySlash = $35;
|
|
||||||
keyInsert = $D2;
|
|
||||||
keyDelete = $D3;
|
|
||||||
keyHome = $C7;
|
|
||||||
keyEnd = $CF;
|
|
||||||
keyPageUp = $C9;
|
|
||||||
keyArrowLeft = $CB;
|
|
||||||
keyArrowRight = $CD;
|
|
||||||
keyArrowUp = $C8;
|
|
||||||
keyArrowDown = $D0;
|
|
||||||
keyKeypad0 = $52;
|
|
||||||
keyKeypad1 = $4F;
|
|
||||||
keyKeypad2 = $50;
|
|
||||||
keyKeypad3 = $51;
|
|
||||||
keyKeypad4 = $4B;
|
|
||||||
keyKeypad5 = $4C;
|
|
||||||
keyKeypad6 = $4D;
|
|
||||||
keyKeypad7 = $47;
|
|
||||||
keyKeypad8 = $48;
|
|
||||||
keyKeypad9 = $49;
|
|
||||||
keyKeypadComma = $53;
|
|
||||||
keyKeypadStar = $37;
|
|
||||||
keyKeypadMinus = $4A;
|
|
||||||
keyKeypadPlus = $4E;
|
|
||||||
keyKeypadEnter = $9C;
|
|
||||||
keyCtrlPrtScr = $B7;
|
|
||||||
keyShiftPrtScr = $B7;
|
|
||||||
keyKeypadSlash = $B5;
|
|
||||||
keyNames : array [0..255] of PChar =
|
|
||||||
( { $00 } nil, 'Esc', '1', '2', '3', '4', '5', '6',
|
|
||||||
{ $08 } '7', '8', '9', '0', '+', 'Apostrophe', 'Backspace', 'Tab',
|
|
||||||
{ $10 } 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
|
|
||||||
{ $18 } 'O', 'P', '<27>', '?', 'Enter', 'Left Ctrl', 'A', 'S',
|
|
||||||
{ $20 } 'D', 'F', 'G', 'H', 'J', 'K', 'L', '<27>',
|
|
||||||
{ $28 } '<27>', '''', 'Left shift', '<', 'Z', 'X', 'C', 'V',
|
|
||||||
{ $30 } 'B', 'N', 'M', ',', '.', '-', 'Right shift', '* (pad)',
|
|
||||||
{ $38 } 'Alt', 'Space', 'Caps Lock', 'F1', 'F2', 'F3', 'F4', 'F5',
|
|
||||||
{ $40 } 'F6', 'F7', 'F8', 'F9', 'F10', 'Num Lock', 'Scroll Lock', '7 (pad)',
|
|
||||||
{ $48 } '8 (pad)', '9 (pad)', '- (pad)', '4 (pad)', '5 (pad)', '6 (pad)', '+ (pad)', '1 (pad)',
|
|
||||||
{ $50 } '2 (pad)', '3 (pad)', '0 (pad)', ', (pad)', 'SysRq', nil, nil, 'F11', 'F12',
|
|
||||||
{ $59 } nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $60 } nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $70 } nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $80 } nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $90 } nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 'Enter (pad)', 'Right Ctrl', nil, nil,
|
|
||||||
{ $A0 } nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $B0 } nil, nil, nil, nil, nil, '/ (pad)', nil, 'PrtScr', 'Alt Gr', nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $C0 } nil, nil, nil, nil, nil, nil, nil, 'Home',
|
|
||||||
{ $C8 } 'Up arrow', 'Page Up', nil, 'Left arrow', nil, 'Right arrow', nil, 'End',
|
|
||||||
{ $D0 } 'Down arrow', nil, 'Insert', 'Delete', nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $E0 } nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
||||||
{ $F0 } nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
procedure InstalarKb;
|
|
||||||
procedure DesinstalarKb;
|
|
||||||
function TeclaPuls( b : byte ) : Boolean;
|
|
||||||
function QTeclaPuls : Boolean;
|
|
||||||
function AgarrarTecla : Byte;
|
|
||||||
procedure BorrarKb;
|
|
||||||
procedure EscriuKb;
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
|
||||||
|
|
||||||
|
|
||||||
var
|
|
||||||
|
|
||||||
uOldInt9 : Pointer; { saves location of old OldInt9 vector }
|
|
||||||
uKeys : array [0..255] of Boolean; { array that holds key values }
|
|
||||||
e0Flag : Byte;
|
|
||||||
uExitProc : Pointer;
|
|
||||||
|
|
||||||
|
|
||||||
{$F+}
|
|
||||||
procedure NewInt9; interrupt; assembler;
|
|
||||||
asm
|
|
||||||
cli
|
|
||||||
in al, $60 { get scan code from keyboard port }
|
|
||||||
cmp al, $E0 { al = $E0 key ? }
|
|
||||||
jne @@SetScanCode
|
|
||||||
mov [e0Flag], 128
|
|
||||||
mov al, 20h { Send 'generic' EOI to PIC }
|
|
||||||
out 20h, al
|
|
||||||
jmp @@exit
|
|
||||||
@@SetScanCode:
|
|
||||||
mov bl, al { Save scancode in BL }
|
|
||||||
and bl, 01111111b
|
|
||||||
add bl, [e0Flag]
|
|
||||||
xor bh, bh
|
|
||||||
and al, 10000000b { keep break bit, if set }
|
|
||||||
xor al, 10000000b { flip bit, 1 means pressed, 0 no }
|
|
||||||
rol al, 1 { move breakbit to bit 0 }
|
|
||||||
mov [offset uKeys + bx], al
|
|
||||||
mov [e0Flag], 0
|
|
||||||
mov al, 20h { send EOI to PIC }
|
|
||||||
out 20h, al
|
|
||||||
@@exit:
|
|
||||||
sti
|
|
||||||
end;
|
|
||||||
{$F-}
|
|
||||||
|
|
||||||
|
|
||||||
procedure InstalarKb;
|
|
||||||
begin
|
|
||||||
GetIntVec( $09, uOldInt9); { save old location of INT 09 handler }
|
|
||||||
SetIntVec( $09, Addr( NewInt9)); { point to new routine }
|
|
||||||
FillChar( uKeys, SizeOf( uKeys), 0); { clear the keys array }
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure DesinstalarKb;
|
|
||||||
begin
|
|
||||||
SetIntVec( $09, uOldInt9); { point back to original routine }
|
|
||||||
uOldInt9 := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function TeclaPuls( b : byte ) : Boolean;
|
|
||||||
begin
|
|
||||||
TeclaPuls := uKeys[b];
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function QTeclaPuls : Boolean;
|
|
||||||
var b : Integer;
|
|
||||||
begin
|
|
||||||
QTeclaPuls := True;
|
|
||||||
for b := 0 to 255 do
|
|
||||||
if uKeys[b] and (keyNames[b] <> nil) then
|
|
||||||
Exit;
|
|
||||||
QTeclaPuls := False;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function AgarrarTecla : Byte;
|
|
||||||
var b : Integer;
|
|
||||||
begin
|
|
||||||
AgarrarTecla := 0;
|
|
||||||
for b := 1 to 255 do
|
|
||||||
if uKeys[b] and (keyNames[b] <> nil) then
|
|
||||||
begin
|
|
||||||
AgarrarTecla := b;
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure BorrarKb;
|
|
||||||
begin
|
|
||||||
FillChar( uKeys, SizeOf( uKeys), 0); { clear the keys array }
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{$F+}
|
|
||||||
procedure CleanUp;
|
|
||||||
begin
|
|
||||||
ExitProc := uExitProc;
|
|
||||||
if uOldInt9 <> nil then
|
|
||||||
DesinstalarKb;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure EscriuKb;
|
|
||||||
var b:byte;
|
|
||||||
begin
|
|
||||||
for b := 0 to 255 do
|
|
||||||
if uKeys[b] and (keyNames[b] <> nil) then
|
|
||||||
write(keyNames[b],' | ');
|
|
||||||
writeln;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{$F-}
|
|
||||||
|
|
||||||
|
|
||||||
begin
|
|
||||||
uExitProc := ExitProc;
|
|
||||||
ExitProc := @CleanUp;
|
|
||||||
uOldInt9 := nil;
|
|
||||||
end.
|
|
||||||
6
Makefile
Normal file
6
Makefile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
macos:
|
||||||
|
mkdir -p bin
|
||||||
|
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -o bin/asteroids_macos
|
||||||
|
linux:
|
||||||
|
mkdir -p bin
|
||||||
|
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -o bin/asteroids_linux
|
||||||
433
source/ASTEROID.PAS
Executable file
433
source/ASTEROID.PAS
Executable file
@@ -0,0 +1,433 @@
|
|||||||
|
uses crt,keyboard,sencos;
|
||||||
|
|
||||||
|
const
|
||||||
|
marge_dalt=20;
|
||||||
|
marge_baix=460;
|
||||||
|
marge_esq=20;
|
||||||
|
marge_dret=620;
|
||||||
|
max_ipunts=30;
|
||||||
|
max_ornis=15;
|
||||||
|
velocitat=2;
|
||||||
|
velocitat_max=6;
|
||||||
|
max_bales=3;
|
||||||
|
type
|
||||||
|
ipunt=RECORD r,angle:real; END;
|
||||||
|
punt=RECORD x,y:integer; END;
|
||||||
|
ivector=array [0..max_ipunts-1] of ipunt;
|
||||||
|
triangle=RECORD p1,p2,p3:ipunt;
|
||||||
|
centre:punt;
|
||||||
|
angle:real;
|
||||||
|
velocitat:real;
|
||||||
|
END;
|
||||||
|
poligon=RECORD ipunts:^ivector;
|
||||||
|
ipuntx:ivector;
|
||||||
|
centre:punt;
|
||||||
|
angle:real;
|
||||||
|
velocitat:real;
|
||||||
|
n:byte;
|
||||||
|
drotacio,rotacio:real;
|
||||||
|
esta:boolean;
|
||||||
|
END;
|
||||||
|
|
||||||
|
|
||||||
|
pvirt=array [1..38400] of byte;
|
||||||
|
|
||||||
|
var nau:triangle;pol:poligon;
|
||||||
|
ang:real;
|
||||||
|
ch:char;
|
||||||
|
Dx,Dy:word;
|
||||||
|
i,aux:byte;
|
||||||
|
dist:integer;
|
||||||
|
puntaux:punt;
|
||||||
|
orni:array [1..max_ornis] of poligon;
|
||||||
|
virt:^pvirt;
|
||||||
|
bales:array [1..max_bales] of poligon;
|
||||||
|
|
||||||
|
procedure volca;
|
||||||
|
var i:word;
|
||||||
|
begin
|
||||||
|
for i:=1 to 38400 do mem[$A000:i]:=mem[seg(virt^):i];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure crear_poligon_regular(var pol:poligon;n:byte;r:real);
|
||||||
|
var i:word;act,interval:real;aux:ipunt;
|
||||||
|
begin
|
||||||
|
{getmem(pol.ipunts,{n*464000);}
|
||||||
|
interval:=2*pi/n;
|
||||||
|
act:=0;
|
||||||
|
for i:=0 to n-1 do begin
|
||||||
|
aux.r:=r;
|
||||||
|
aux.angle:=act;
|
||||||
|
pol.ipuntx[i]:=aux;
|
||||||
|
act:=act + interval;
|
||||||
|
end;
|
||||||
|
pol.centre.x:=320;
|
||||||
|
pol.centre.y:=200;
|
||||||
|
pol.angle:=0;
|
||||||
|
pol.velocitat:=velocitat;
|
||||||
|
pol.n:=n;
|
||||||
|
pol.drotacio:=0.078539816;
|
||||||
|
pol.rotacio:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MCGA;
|
||||||
|
begin
|
||||||
|
asm
|
||||||
|
mov ax,0012h
|
||||||
|
int 10h
|
||||||
|
end;
|
||||||
|
directvideo:= false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Text;
|
||||||
|
begin
|
||||||
|
asm
|
||||||
|
mov ax,0003h
|
||||||
|
int 10h
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure WaitRetrace; assembler;
|
||||||
|
label
|
||||||
|
l1,l2;
|
||||||
|
|
||||||
|
asm
|
||||||
|
mov dx,3DAh
|
||||||
|
|
||||||
|
l1:
|
||||||
|
in al,dx
|
||||||
|
and al,08h
|
||||||
|
jnz l1
|
||||||
|
|
||||||
|
l2:
|
||||||
|
in al,dx
|
||||||
|
and al,08h
|
||||||
|
jz l2
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure posa(x,y:word;color:byte);
|
||||||
|
begin
|
||||||
|
if color=1 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $7F)OR $80;
|
||||||
|
1:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $BF)OR $40;
|
||||||
|
2:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $DF)OR $20;
|
||||||
|
3:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $EF)OR $10;
|
||||||
|
4:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $F7)OR $08;
|
||||||
|
5:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FB)OR $04;
|
||||||
|
6:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FD)OR $02;
|
||||||
|
7:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FE)OR $01;
|
||||||
|
end;
|
||||||
|
if color=0 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $7F);
|
||||||
|
1:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $BF);
|
||||||
|
2:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $DF);
|
||||||
|
3:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $EF);
|
||||||
|
4:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $F7);
|
||||||
|
5:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FB);
|
||||||
|
6:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FD);
|
||||||
|
7:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FE);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function llig(x,y:word):byte;
|
||||||
|
begin
|
||||||
|
case (x mod 8) of
|
||||||
|
0:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $80)shr 7;
|
||||||
|
1:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $40)shr 6;
|
||||||
|
2:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $20)shr 5;
|
||||||
|
3:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $10)shr 4;
|
||||||
|
4:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $08)shr 3;
|
||||||
|
5:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $04)shr 2;
|
||||||
|
6:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $02)shr 1;
|
||||||
|
7:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $01);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure posavga(x,y:word;color:byte);
|
||||||
|
begin
|
||||||
|
if color=1 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $7F)OR $80;
|
||||||
|
1:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $BF)OR $40;
|
||||||
|
2:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $DF)OR $20;
|
||||||
|
3:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $EF)OR $10;
|
||||||
|
4:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $F7)OR $08;
|
||||||
|
5:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FB)OR $04;
|
||||||
|
6:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FD)OR $02;
|
||||||
|
7:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FE)OR $01;
|
||||||
|
end;
|
||||||
|
if color=0 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $7F);
|
||||||
|
1:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $BF);
|
||||||
|
2:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $DF);
|
||||||
|
3:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $EF);
|
||||||
|
4:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $F7);
|
||||||
|
5:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FB);
|
||||||
|
6:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FD);
|
||||||
|
7:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FE);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function modul(p:punt):real;
|
||||||
|
begin
|
||||||
|
modul:=sqrt(sqr(p.x)+sqr(p.y));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure diferencia(o,d:punt;var p:punt);
|
||||||
|
begin
|
||||||
|
p.x:=o.x-d.x;
|
||||||
|
p.y:=o.y-d.y;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function distancia(o,d:punt):integer;
|
||||||
|
var p:punt;
|
||||||
|
begin
|
||||||
|
diferencia(o,d,p);
|
||||||
|
distancia:=round(modul(p));
|
||||||
|
end;
|
||||||
|
function angle(p:punt):real;
|
||||||
|
begin
|
||||||
|
if p.y<>0 then angle:=arctan(p.x/p.y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure clsvirt;
|
||||||
|
var i:word;
|
||||||
|
begin
|
||||||
|
for i:=1 to 38400 do mem[seg(virt^):i]:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function linea(x1,y1,x2,y2,color:word):boolean;
|
||||||
|
|
||||||
|
function sign(x:integer):integer; {like sgn(x) in basic}
|
||||||
|
begin if x<0 then sign:=-1 else if x>0 then sign:=1 else sign:=0 end;
|
||||||
|
|
||||||
|
var
|
||||||
|
x,y,count,xs,ys,xm,ym,col:integer;
|
||||||
|
begin
|
||||||
|
linea:=false;
|
||||||
|
col:=0;
|
||||||
|
x:=x1;y:=y1;
|
||||||
|
|
||||||
|
xs:=x2-x1; ys:=y2-y1;
|
||||||
|
|
||||||
|
xm:=sign(xs); ym:=sign(ys);
|
||||||
|
xs:=abs(xs); ys:=abs(ys);
|
||||||
|
if llig(x,y)=1 then inc(col);
|
||||||
|
posa(x,y,color);
|
||||||
|
|
||||||
|
if xs > ys
|
||||||
|
then begin {flat line <45 deg}
|
||||||
|
count:=-(xs div 2);
|
||||||
|
while (x <> x2 ) do begin
|
||||||
|
count:=count+ys;
|
||||||
|
x:=x+xm;
|
||||||
|
if count>0 then begin
|
||||||
|
y:=y+ym;
|
||||||
|
count:=count-xs;
|
||||||
|
end;
|
||||||
|
if llig(x,y)=1 then inc(col);
|
||||||
|
posa(x,y,color);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else begin {steep line >=45 deg}
|
||||||
|
count:=-(ys div 2);
|
||||||
|
while (y <> y2 ) do begin
|
||||||
|
count:=count+xs;
|
||||||
|
y:=y+ym;
|
||||||
|
if count>0 then begin
|
||||||
|
x:=x+xm;
|
||||||
|
count:=count-ys;
|
||||||
|
end;
|
||||||
|
if llig(x,y)=1 then inc(col);
|
||||||
|
posa(x,y,color);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if col>2 then linea:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function rota_tri(tri:triangle;angul,velocitat:real;color:byte):byte;
|
||||||
|
var x1,x2,x3,y1,y2,y3:word;
|
||||||
|
begin
|
||||||
|
x1:=round((tri.p1.r+velocitat)*cos(tri.p1.angle+angul))+tri.centre.x;
|
||||||
|
x2:=round((tri.p2.r+velocitat)*cos(tri.p2.angle+angul{+velocitat/20}))+tri.centre.x;
|
||||||
|
x3:=round((tri.p3.r+velocitat)*cos(tri.p3.angle+angul{-velocitat/20}))+tri.centre.x;
|
||||||
|
y1:=round((tri.p1.r+velocitat)*sin(tri.p1.angle+angul))+tri.centre.y;
|
||||||
|
y2:=round((tri.p2.r+velocitat)*sin(tri.p2.angle+angul{+velocitat/20}))+tri.centre.y;
|
||||||
|
y3:=round((tri.p3.r+velocitat)*sin(tri.p3.angle+angul{-velocitat/20}))+tri.centre.y;
|
||||||
|
rota_tri:=0;
|
||||||
|
if linea(x1,y1,x2,y2,color) then rota_tri:=1 ;
|
||||||
|
if linea(x1,y1,x3,y3,color) then rota_tri:=1;
|
||||||
|
if linea(x3,y3,x2,y2,color) then rota_tri:=1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure rota_pol(pol:poligon;angul:real;color:byte);
|
||||||
|
var xy:array [0..max_ipunts] of punt;i:byte;
|
||||||
|
begin
|
||||||
|
for i:=0 to pol.n-1 do begin
|
||||||
|
xy[i].x:=round((pol.ipuntx[i].r)*cos(pol.ipuntx[i].angle+angul))+pol.centre.x;
|
||||||
|
xy[i].y:=round((pol.ipuntx[i].r)*sin(pol.ipuntx[i].angle+angul))+pol.centre.y;
|
||||||
|
end;
|
||||||
|
for i:=0 to pol.n-2 do
|
||||||
|
linea(xy[i].x,xy[i].y,xy[i+1].x,xy[i+1].y,color);
|
||||||
|
linea(xy[pol.n-1].x,xy[pol.n-1].y,xy[0].x,xy[0].y,color);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure mou_orni(var orni:poligon);
|
||||||
|
var dx,dy:real;
|
||||||
|
begin
|
||||||
|
orni.angle:=orni.angle{+(random(256)/512)*(random(3)-1)};
|
||||||
|
Dy:=round(orni.velocitat*sin(orni.angle-pi/2))+orni.centre.y;
|
||||||
|
Dx:=round(orni.velocitat*cos(orni.angle-pi/2))+orni.centre.x;
|
||||||
|
if (dy>marge_dalt) and (dy<marge_baix) then
|
||||||
|
orni.centre.y:=round(Dy)
|
||||||
|
else orni.angle:=orni.angle+(random(256)/512)*(random(3)-1);
|
||||||
|
|
||||||
|
if (dx>marge_esq) and (dx<marge_dret) then
|
||||||
|
orni.centre.x:=round(Dx)
|
||||||
|
else orni.angle:=orni.angle+(random(256)/512)*(random(3)-1);
|
||||||
|
orni.rotacio:=orni.rotacio+orni.drotacio;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure mou_bales(var orni:poligon);
|
||||||
|
var dx,dy:real;
|
||||||
|
begin
|
||||||
|
orni.angle:=orni.angle{+(random(256)/512)*(random(3)-1)};
|
||||||
|
Dy:=round(orni.velocitat*sin(orni.angle-pi/2))+orni.centre.y;
|
||||||
|
Dx:=round(orni.velocitat*cos(orni.angle-pi/2))+orni.centre.x;
|
||||||
|
if (dy>marge_dalt) and (dy<marge_baix) then
|
||||||
|
orni.centre.y:=round(Dy)
|
||||||
|
else {orni.angle:=orni.angle+(random(256)/512)*(random(3)-1)}orni.esta:=false;
|
||||||
|
|
||||||
|
if (dx>marge_esq) and (dx<marge_dret) then
|
||||||
|
orni.centre.x:=round(Dx)
|
||||||
|
else {orni.angle:=orni.angle+(random(256)/512)*(random(3)-1)}orni.esta:=false;;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var itocado:word;
|
||||||
|
chatarra_cosmica:poligon;
|
||||||
|
|
||||||
|
procedure tocado;
|
||||||
|
var i,j,k:word;dx,dy:word;
|
||||||
|
begin
|
||||||
|
if itocado=1 then begin
|
||||||
|
chatarra_cosmica.centre.x:=nau.centre.x;
|
||||||
|
chatarra_cosmica.centre.y:=nau.centre.y;
|
||||||
|
chatarra_cosmica.n:=max_ipunts;
|
||||||
|
for i:=0 to max_ipunts-1 do begin
|
||||||
|
chatarra_cosmica.ipuntx[i].r:=1;
|
||||||
|
chatarra_cosmica.ipuntx[i].angle:=random(360)*57.295779513;
|
||||||
|
end;
|
||||||
|
nau.velocitat:=0;
|
||||||
|
end;
|
||||||
|
if ((nau.p1.r>1) and (nau.p2.r>1)and (nau.p3.r>1)and (itocado<170)) then begin
|
||||||
|
nau.p1.r:=nau.p1.r-0.7;
|
||||||
|
nau.p2.r:=nau.p2.r-0.7;
|
||||||
|
nau.p3.r:=nau.p3.r-0.7;
|
||||||
|
nau.angle:=nau.angle-0.3;
|
||||||
|
rota_tri(nau,nau.angle,0,1);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
for i:=0 to max_ipunts-1 do begin
|
||||||
|
chatarra_cosmica.ipuntx[i].r:=chatarra_cosmica.ipuntx[i].r+3;
|
||||||
|
dx:=round((chatarra_cosmica.ipuntx[i].r)*cos(chatarra_cosmica.ipuntx[i].angle))
|
||||||
|
+chatarra_cosmica.centre.x;
|
||||||
|
dy:=round((chatarra_cosmica.ipuntx[i].r)*sin(chatarra_cosmica.ipuntx[i].angle))
|
||||||
|
+chatarra_cosmica.centre.y;
|
||||||
|
if ((dx>=0)AND(dx<640)AND(dy>0)AND(dy<480))then posa(dx,dy,1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
inc(itocado);
|
||||||
|
if itocado=170 then begin
|
||||||
|
nau.p1.r:=12;nau.p1.angle:=3*pi/2;
|
||||||
|
nau.p2.r:=12;nau.p2.angle:=pi/4;
|
||||||
|
nau.p3.r:=12;nau.p3.angle:=(3*pi)/4;
|
||||||
|
nau.angle:=0;
|
||||||
|
nau.centre.x:=320;nau.centre.y:=240;
|
||||||
|
end;
|
||||||
|
if ((itocado>170)and(itocado mod 3=0)) then rota_tri(nau,nau.angle,nau.velocitat,1);
|
||||||
|
if itocado>250 then itocado:=0;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
randomize;
|
||||||
|
getmem(virt,38400);
|
||||||
|
itocado:=0;
|
||||||
|
clsvirt;
|
||||||
|
nau.p1.r:=12;nau.p1.angle:=3*pi/2;
|
||||||
|
nau.p2.r:=12;nau.p2.angle:=pi/4;
|
||||||
|
nau.p3.r:=12;nau.p3.angle:=(3*pi)/4;
|
||||||
|
nau.angle:=0;
|
||||||
|
nau.centre.x:=320;nau.centre.y:=240;
|
||||||
|
crear_poligon_regular(pol,10,200);
|
||||||
|
for i:=1 to max_ornis do crear_poligon_regular(orni[i],5,20);
|
||||||
|
mcga;
|
||||||
|
rota_pol(pol,0,1);
|
||||||
|
instalarkb;
|
||||||
|
repeat
|
||||||
|
{ rota_tri(nau,nau.angle,nau.velocitat,0);}
|
||||||
|
clsvirt;
|
||||||
|
|
||||||
|
if teclapuls(KEYarrowright) then nau.angle:=nau.angle+0.157079632;
|
||||||
|
if teclapuls(KEYarrowleft) then nau.angle:=nau.angle-0.157079632;
|
||||||
|
if teclapuls(KEYarrowup) then begin
|
||||||
|
if nau.velocitat<velocitat_max then nau.velocitat:=nau.velocitat+0.2;
|
||||||
|
end;
|
||||||
|
if teclapuls(KEYspace)and(bales[1].esta=false) then begin
|
||||||
|
bales[1].esta:=true;
|
||||||
|
bales[1].centre.x:=nau.centre.x;
|
||||||
|
bales[1].centre.y:=nau.centre.y;
|
||||||
|
bales[1].n:=2;
|
||||||
|
bales[1].velocitat:=7;
|
||||||
|
bales[1].ipuntx[1].r:=10;
|
||||||
|
bales[1].ipuntx[1].angle:=pi/2+nau.angle;
|
||||||
|
bales[1].ipuntx[2].r:=20;
|
||||||
|
bales[1].ipuntx[2].angle:=pi/2+nau.angle;
|
||||||
|
bales[1].angle:=nau.angle;
|
||||||
|
end;
|
||||||
|
Dy:=round(nau.velocitat*sin(nau.angle-pi/2))+nau.centre.y;
|
||||||
|
Dx:=round(nau.velocitat*cos(nau.angle-pi/2))+nau.centre.x;
|
||||||
|
if (dy>marge_dalt) and (dy<marge_baix) then
|
||||||
|
nau.centre.y:=Dy;
|
||||||
|
if (dx>marge_esq) and (dx<marge_dret) then
|
||||||
|
nau.centre.x:=Dx;
|
||||||
|
if (nau.velocitat>0.1) then nau.velocitat:=nau.velocitat-0.1;
|
||||||
|
{ dist:=distancia(nau.centre,pol.centre);
|
||||||
|
diferencia(pol.centre,nau.centre,puntaux);
|
||||||
|
if dist<(pol.ipuntx[1].r+30) then begin
|
||||||
|
nau.centre.x:=nau.centre.x
|
||||||
|
+round(dist*cos(angle(puntaux)+0.031415));
|
||||||
|
nau.centre.y:=nau.centre.y
|
||||||
|
+round(dist*sin(angle(puntaux)+0.031415));
|
||||||
|
end;}
|
||||||
|
{ for i:=1 to 5 do begin
|
||||||
|
rota_pol(orni[i],ang,0);
|
||||||
|
end;}
|
||||||
|
for i:=1 to max_ornis do begin
|
||||||
|
mou_orni(orni[i]);
|
||||||
|
rota_pol(orni[i],orni[i].rotacio,1);
|
||||||
|
end;
|
||||||
|
if itocado=0 then aux:=rota_tri(nau,nau.angle,nau.velocitat,1)
|
||||||
|
else tocado;
|
||||||
|
if (aux=1) then begin inc(itocado);aux:=0;end;
|
||||||
|
if bales[1].esta then begin
|
||||||
|
mou_bales(bales[1]);
|
||||||
|
rota_pol(bales[1],0,1);
|
||||||
|
end;
|
||||||
|
waitretrace;
|
||||||
|
volca;
|
||||||
|
{ if aux=1 then begin {gotoxy(0,0);write('tocado')tocado;delay(200);end;}
|
||||||
|
gotoxy(50,24);
|
||||||
|
write('<27> Visente i Sergi');
|
||||||
|
gotoxy(50,25);
|
||||||
|
write('<27>ETA 2.2 2/6/99');
|
||||||
|
until teclapuls(keyesc);
|
||||||
|
desinstalarkb;
|
||||||
|
ang:=0;
|
||||||
|
repeat waitretrace;rota_pol(pol,ang,0); ang:=ang+0.031415 ;rota_pol(pol,ang,1);until keypressed;
|
||||||
|
text;
|
||||||
|
end.
|
||||||
452
source/asteroids.cpp
Executable file
452
source/asteroids.cpp
Executable file
@@ -0,0 +1,452 @@
|
|||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#define MARGE_DALT 20
|
||||||
|
#define MARGE_BAIX 460
|
||||||
|
#define MARGE_ESQ 20
|
||||||
|
#define MARGE_DRET 620
|
||||||
|
#define MAX_IPUNTS 30
|
||||||
|
#define MAX_ORNIS 15
|
||||||
|
#define VELOCITAT 2
|
||||||
|
#define VELOCITAT_MAX 6
|
||||||
|
#define MAX_BALES 3
|
||||||
|
|
||||||
|
struct ipunt
|
||||||
|
{
|
||||||
|
float r;
|
||||||
|
float angle;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct punt
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct triangle
|
||||||
|
{
|
||||||
|
ipunt p1, p2, p3;
|
||||||
|
punt centre;
|
||||||
|
float angle;
|
||||||
|
float velocitat;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<ipunt> ivector();
|
||||||
|
|
||||||
|
struct poligon
|
||||||
|
{
|
||||||
|
ivector *ipunts;
|
||||||
|
ivector ipuntx;
|
||||||
|
punt centre;
|
||||||
|
float angl;
|
||||||
|
float velocitat;
|
||||||
|
Uint8 n;
|
||||||
|
float drotacio;
|
||||||
|
float rotacio;
|
||||||
|
bool esta;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Uint8> pvirt(38400);
|
||||||
|
|
||||||
|
triangle nau;
|
||||||
|
poligon pol;
|
||||||
|
float ang;
|
||||||
|
std::string ch;
|
||||||
|
Uint16 Dx, Dy;
|
||||||
|
Uint8 i, aux;
|
||||||
|
int dist;
|
||||||
|
punt puntaux;
|
||||||
|
std::vector<poligon> orni(MAX_ORNIS);
|
||||||
|
std::vector<poligon> bales(MAX_BALES);
|
||||||
|
virt : ^pvirt;
|
||||||
|
|
||||||
|
procedure volca;
|
||||||
|
var i:word;
|
||||||
|
begin
|
||||||
|
for i:=1 to 38400 do mem[$A000:i]:=mem[seg(virt^):i];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure crear_poligon_regular(var pol:poligon;n:byte;r:real);
|
||||||
|
var i:word;act,interval:real;aux:ipunt;
|
||||||
|
begin
|
||||||
|
{getmem(pol.ipunts,{n*464000);}
|
||||||
|
interval:=2*pi/n;
|
||||||
|
act:=0;
|
||||||
|
for i:=0 to n-1 do begin
|
||||||
|
aux.r:=r;
|
||||||
|
aux.angle:=act;
|
||||||
|
pol.ipuntx[i]:=aux;
|
||||||
|
act:=act + interval;
|
||||||
|
end;
|
||||||
|
pol.centre.x:=320;
|
||||||
|
pol.centre.y:=200;
|
||||||
|
pol.angle:=0;
|
||||||
|
pol.velocitat:=velocitat;
|
||||||
|
pol.n:=n;
|
||||||
|
pol.drotacio:=0.078539816;
|
||||||
|
pol.rotacio:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure MCGA;
|
||||||
|
begin
|
||||||
|
asm
|
||||||
|
mov ax,0012h
|
||||||
|
int 10h
|
||||||
|
end;
|
||||||
|
directvideo:= false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Text;
|
||||||
|
begin
|
||||||
|
asm
|
||||||
|
mov ax,0003h
|
||||||
|
int 10h
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure WaitRetrace; assembler;
|
||||||
|
label
|
||||||
|
l1,l2;
|
||||||
|
|
||||||
|
asm
|
||||||
|
mov dx,3DAh
|
||||||
|
|
||||||
|
l1:
|
||||||
|
in al,dx
|
||||||
|
and al,08h
|
||||||
|
jnz l1
|
||||||
|
|
||||||
|
l2:
|
||||||
|
in al,dx
|
||||||
|
and al,08h
|
||||||
|
jz l2
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure posa(x,y:word;color:byte);
|
||||||
|
begin
|
||||||
|
if color=1 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $7F)OR $80;
|
||||||
|
1:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $BF)OR $40;
|
||||||
|
2:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $DF)OR $20;
|
||||||
|
3:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $EF)OR $10;
|
||||||
|
4:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $F7)OR $08;
|
||||||
|
5:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FB)OR $04;
|
||||||
|
6:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FD)OR $02;
|
||||||
|
7:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FE)OR $01;
|
||||||
|
end;
|
||||||
|
if color=0 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $7F);
|
||||||
|
1:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $BF);
|
||||||
|
2:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $DF);
|
||||||
|
3:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $EF);
|
||||||
|
4:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $F7);
|
||||||
|
5:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FB);
|
||||||
|
6:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FD);
|
||||||
|
7:mem[seg(virt^):y*80+(x div 8)]:=(mem[seg(virt^):y*80+(x div 8)]AND $FE);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function llig(x,y:word):byte;
|
||||||
|
begin
|
||||||
|
case (x mod 8) of
|
||||||
|
0:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $80)shr 7;
|
||||||
|
1:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $40)shr 6;
|
||||||
|
2:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $20)shr 5;
|
||||||
|
3:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $10)shr 4;
|
||||||
|
4:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $08)shr 3;
|
||||||
|
5:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $04)shr 2;
|
||||||
|
6:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $02)shr 1;
|
||||||
|
7:llig:=(mem[seg(virt^):y*80+(x div 8)]AND $01);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure posavga(x,y:word;color:byte);
|
||||||
|
begin
|
||||||
|
if color=1 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $7F)OR $80;
|
||||||
|
1:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $BF)OR $40;
|
||||||
|
2:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $DF)OR $20;
|
||||||
|
3:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $EF)OR $10;
|
||||||
|
4:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $F7)OR $08;
|
||||||
|
5:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FB)OR $04;
|
||||||
|
6:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FD)OR $02;
|
||||||
|
7:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FE)OR $01;
|
||||||
|
end;
|
||||||
|
if color=0 then
|
||||||
|
case (x mod 8) of
|
||||||
|
0:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $7F);
|
||||||
|
1:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $BF);
|
||||||
|
2:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $DF);
|
||||||
|
3:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $EF);
|
||||||
|
4:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $F7);
|
||||||
|
5:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FB);
|
||||||
|
6:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FD);
|
||||||
|
7:mem[$A000:y*80+(x div 8)]:=(mem[$A000:y*80+(x div 8)]AND $FE);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function modul(p:punt):real;
|
||||||
|
begin
|
||||||
|
modul:=sqrt(sqr(p.x)+sqr(p.y));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure diferencia(o,d:punt;var p:punt);
|
||||||
|
begin
|
||||||
|
p.x:=o.x-d.x;
|
||||||
|
p.y:=o.y-d.y;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function distancia(o,d:punt):integer;
|
||||||
|
var p:punt;
|
||||||
|
begin
|
||||||
|
diferencia(o,d,p);
|
||||||
|
distancia:=round(modul(p));
|
||||||
|
end;
|
||||||
|
function angle(p:punt):real;
|
||||||
|
begin
|
||||||
|
if p.y<>0 then angle:=arctan(p.x/p.y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure clsvirt;
|
||||||
|
var i:word;
|
||||||
|
begin
|
||||||
|
for i:=1 to 38400 do mem[seg(virt^):i]:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function linea(x1,y1,x2,y2,color:word):boolean;
|
||||||
|
|
||||||
|
function sign(x:integer):integer; {like sgn(x) in basic}
|
||||||
|
begin if x<0 then sign:=-1 else if x>0 then sign:=1 else sign:=0 end;
|
||||||
|
|
||||||
|
var
|
||||||
|
x,y,count,xs,ys,xm,ym,col:integer;
|
||||||
|
begin
|
||||||
|
linea:=false;
|
||||||
|
col:=0;
|
||||||
|
x:=x1;y:=y1;
|
||||||
|
|
||||||
|
xs:=x2-x1; ys:=y2-y1;
|
||||||
|
|
||||||
|
xm:=sign(xs); ym:=sign(ys);
|
||||||
|
xs:=abs(xs); ys:=abs(ys);
|
||||||
|
if llig(x,y)=1 then inc(col);
|
||||||
|
posa(x,y,color);
|
||||||
|
|
||||||
|
if xs > ys
|
||||||
|
then begin {flat line <45 deg}
|
||||||
|
count:=-(xs div 2);
|
||||||
|
while (x <> x2 ) do begin
|
||||||
|
count:=count+ys;
|
||||||
|
x:=x+xm;
|
||||||
|
if count>0 then begin
|
||||||
|
y:=y+ym;
|
||||||
|
count:=count-xs;
|
||||||
|
end;
|
||||||
|
if llig(x,y)=1 then inc(col);
|
||||||
|
posa(x,y,color);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else begin {steep line >=45 deg}
|
||||||
|
count:=-(ys div 2);
|
||||||
|
while (y <> y2 ) do begin
|
||||||
|
count:=count+xs;
|
||||||
|
y:=y+ym;
|
||||||
|
if count>0 then begin
|
||||||
|
x:=x+xm;
|
||||||
|
count:=count-ys;
|
||||||
|
end;
|
||||||
|
if llig(x,y)=1 then inc(col);
|
||||||
|
posa(x,y,color);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if col>2 then linea:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function rota_tri(tri:triangle;angul,velocitat:real;color:byte):byte;
|
||||||
|
var x1,x2,x3,y1,y2,y3:word;
|
||||||
|
begin
|
||||||
|
x1:=round((tri.p1.r+velocitat)*cos(tri.p1.angle+angul))+tri.centre.x;
|
||||||
|
x2:=round((tri.p2.r+velocitat)*cos(tri.p2.angle+angul{+velocitat/20}))+tri.centre.x;
|
||||||
|
x3:=round((tri.p3.r+velocitat)*cos(tri.p3.angle+angul{-velocitat/20}))+tri.centre.x;
|
||||||
|
y1:=round((tri.p1.r+velocitat)*sin(tri.p1.angle+angul))+tri.centre.y;
|
||||||
|
y2:=round((tri.p2.r+velocitat)*sin(tri.p2.angle+angul{+velocitat/20}))+tri.centre.y;
|
||||||
|
y3:=round((tri.p3.r+velocitat)*sin(tri.p3.angle+angul{-velocitat/20}))+tri.centre.y;
|
||||||
|
rota_tri:=0;
|
||||||
|
if linea(x1,y1,x2,y2,color) then rota_tri:=1 ;
|
||||||
|
if linea(x1,y1,x3,y3,color) then rota_tri:=1;
|
||||||
|
if linea(x3,y3,x2,y2,color) then rota_tri:=1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure rota_pol(pol:poligon;angul:real;color:byte);
|
||||||
|
var xy:array [0..MAX_IPUNTS] of punt;i:byte;
|
||||||
|
begin
|
||||||
|
for i:=0 to pol.n-1 do begin
|
||||||
|
xy[i].x:=round((pol.ipuntx[i].r)*cos(pol.ipuntx[i].angle+angul))+pol.centre.x;
|
||||||
|
xy[i].y:=round((pol.ipuntx[i].r)*sin(pol.ipuntx[i].angle+angul))+pol.centre.y;
|
||||||
|
end;
|
||||||
|
for i:=0 to pol.n-2 do
|
||||||
|
linea(xy[i].x,xy[i].y,xy[i+1].x,xy[i+1].y,color);
|
||||||
|
linea(xy[pol.n-1].x,xy[pol.n-1].y,xy[0].x,xy[0].y,color);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure mou_orni(var orni:poligon);
|
||||||
|
var dx,dy:real;
|
||||||
|
begin
|
||||||
|
orni.angle:=orni.angle{+(random(256)/512)*(random(3)-1)};
|
||||||
|
Dy:=round(orni.velocitat*sin(orni.angle-pi/2))+orni.centre.y;
|
||||||
|
Dx:=round(orni.velocitat*cos(orni.angle-pi/2))+orni.centre.x;
|
||||||
|
if (dy>MARGE_DALT) and (dy<MARGE_BAIX) then
|
||||||
|
orni.centre.y:=round(Dy)
|
||||||
|
else orni.angle:=orni.angle+(random(256)/512)*(random(3)-1);
|
||||||
|
|
||||||
|
if (dx>MARGE_ESQ) and (dx<MARGE_DRET) then
|
||||||
|
orni.centre.x:=round(Dx)
|
||||||
|
else orni.angle:=orni.angle+(random(256)/512)*(random(3)-1);
|
||||||
|
orni.rotacio:=orni.rotacio+orni.drotacio;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure mou_bales(var orni:poligon);
|
||||||
|
var dx,dy:real;
|
||||||
|
begin
|
||||||
|
orni.angle:=orni.angle{+(random(256)/512)*(random(3)-1)};
|
||||||
|
Dy:=round(orni.velocitat*sin(orni.angle-pi/2))+orni.centre.y;
|
||||||
|
Dx:=round(orni.velocitat*cos(orni.angle-pi/2))+orni.centre.x;
|
||||||
|
if (dy>MARGE_DALT) and (dy<MARGE_BAIX) then
|
||||||
|
orni.centre.y:=round(Dy)
|
||||||
|
else {orni.angle:=orni.angle+(random(256)/512)*(random(3)-1)}orni.esta:=false;
|
||||||
|
|
||||||
|
if (dx>MARGE_ESQ) and (dx<MARGE_DRET) then
|
||||||
|
orni.centre.x:=round(Dx)
|
||||||
|
else {orni.angle:=orni.angle+(random(256)/512)*(random(3)-1)}orni.esta:=false;;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var itocado:word;
|
||||||
|
chatarra_cosmica:poligon;
|
||||||
|
|
||||||
|
procedure tocado;
|
||||||
|
var i,j,k:word;dx,dy:word;
|
||||||
|
begin
|
||||||
|
if itocado=1 then begin
|
||||||
|
chatarra_cosmica.centre.x:=nau.centre.x;
|
||||||
|
chatarra_cosmica.centre.y:=nau.centre.y;
|
||||||
|
chatarra_cosmica.n:=MAX_IPUNTS;
|
||||||
|
for i:=0 to MAX_IPUNTS-1 do begin
|
||||||
|
chatarra_cosmica.ipuntx[i].r:=1;
|
||||||
|
chatarra_cosmica.ipuntx[i].angle:=random(360)*57.295779513;
|
||||||
|
end;
|
||||||
|
nau.velocitat:=0;
|
||||||
|
end;
|
||||||
|
if ((nau.p1.r>1) and (nau.p2.r>1)and (nau.p3.r>1)and (itocado<170)) then begin
|
||||||
|
nau.p1.r:=nau.p1.r-0.7;
|
||||||
|
nau.p2.r:=nau.p2.r-0.7;
|
||||||
|
nau.p3.r:=nau.p3.r-0.7;
|
||||||
|
nau.angle:=nau.angle-0.3;
|
||||||
|
rota_tri(nau,nau.angle,0,1);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
for i:=0 to MAX_IPUNTS-1 do begin
|
||||||
|
chatarra_cosmica.ipuntx[i].r:=chatarra_cosmica.ipuntx[i].r+3;
|
||||||
|
dx:=round((chatarra_cosmica.ipuntx[i].r)*cos(chatarra_cosmica.ipuntx[i].angle))
|
||||||
|
+chatarra_cosmica.centre.x;
|
||||||
|
dy:=round((chatarra_cosmica.ipuntx[i].r)*sin(chatarra_cosmica.ipuntx[i].angle))
|
||||||
|
+chatarra_cosmica.centre.y;
|
||||||
|
if ((dx>=0)AND(dx<640)AND(dy>0)AND(dy<480))then posa(dx,dy,1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
inc(itocado);
|
||||||
|
if itocado=170 then begin
|
||||||
|
nau.p1.r:=12;nau.p1.angle:=3*pi/2;
|
||||||
|
nau.p2.r:=12;nau.p2.angle:=pi/4;
|
||||||
|
nau.p3.r:=12;nau.p3.angle:=(3*pi)/4;
|
||||||
|
nau.angle:=0;
|
||||||
|
nau.centre.x:=320;nau.centre.y:=240;
|
||||||
|
end;
|
||||||
|
if ((itocado>170)and(itocado mod 3=0)) then rota_tri(nau,nau.angle,nau.velocitat,1);
|
||||||
|
if itocado>250 then itocado:=0;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
randomize;
|
||||||
|
getmem(virt,38400);
|
||||||
|
itocado:=0;
|
||||||
|
clsvirt;
|
||||||
|
nau.p1.r:=12;nau.p1.angle:=3*pi/2;
|
||||||
|
nau.p2.r:=12;nau.p2.angle:=pi/4;
|
||||||
|
nau.p3.r:=12;nau.p3.angle:=(3*pi)/4;
|
||||||
|
nau.angle:=0;
|
||||||
|
nau.centre.x:=320;nau.centre.y:=240;
|
||||||
|
crear_poligon_regular(pol,10,200);
|
||||||
|
for i:=1 to MAX_ORNIS do crear_poligon_regular(orni[i],5,20);
|
||||||
|
mcga;
|
||||||
|
rota_pol(pol,0,1);
|
||||||
|
instalarkb;
|
||||||
|
repeat
|
||||||
|
{ rota_tri(nau,nau.angle,nau.velocitat,0);}
|
||||||
|
clsvirt;
|
||||||
|
|
||||||
|
if teclapuls(KEYarrowright) then nau.angle:=nau.angle+0.157079632;
|
||||||
|
if teclapuls(KEYarrowleft) then nau.angle:=nau.angle-0.157079632;
|
||||||
|
if teclapuls(KEYarrowup) then begin
|
||||||
|
if nau.velocitat<VELOCITAT_MAX then nau.velocitat:=nau.velocitat+0.2;
|
||||||
|
end;
|
||||||
|
if teclapuls(KEYspace)and(bales[1].esta=false) then begin
|
||||||
|
bales[1].esta:=true;
|
||||||
|
bales[1].centre.x:=nau.centre.x;
|
||||||
|
bales[1].centre.y:=nau.centre.y;
|
||||||
|
bales[1].n:=2;
|
||||||
|
bales[1].velocitat:=7;
|
||||||
|
bales[1].ipuntx[1].r:=10;
|
||||||
|
bales[1].ipuntx[1].angle:=pi/2+nau.angle;
|
||||||
|
bales[1].ipuntx[2].r:=20;
|
||||||
|
bales[1].ipuntx[2].angle:=pi/2+nau.angle;
|
||||||
|
bales[1].angle:=nau.angle;
|
||||||
|
end;
|
||||||
|
Dy:=round(nau.velocitat*sin(nau.angle-pi/2))+nau.centre.y;
|
||||||
|
Dx:=round(nau.velocitat*cos(nau.angle-pi/2))+nau.centre.x;
|
||||||
|
if (dy>MARGE_DALT) and (dy<MARGE_BAIX) then
|
||||||
|
nau.centre.y:=Dy;
|
||||||
|
if (dx>MARGE_ESQ) and (dx<MARGE_DRET) then
|
||||||
|
nau.centre.x:=Dx;
|
||||||
|
if (nau.velocitat>0.1) then nau.velocitat:=nau.velocitat-0.1;
|
||||||
|
{ dist:=distancia(nau.centre,pol.centre);
|
||||||
|
diferencia(pol.centre,nau.centre,puntaux);
|
||||||
|
if dist<(pol.ipuntx[1].r+30) then begin
|
||||||
|
nau.centre.x:=nau.centre.x
|
||||||
|
+round(dist*cos(angle(puntaux)+0.031415));
|
||||||
|
nau.centre.y:=nau.centre.y
|
||||||
|
+round(dist*sin(angle(puntaux)+0.031415));
|
||||||
|
end;}
|
||||||
|
{ for i:=1 to 5 do begin
|
||||||
|
rota_pol(orni[i],ang,0);
|
||||||
|
end;}
|
||||||
|
for i:=1 to MAX_ORNIS do begin
|
||||||
|
mou_orni(orni[i]);
|
||||||
|
rota_pol(orni[i],orni[i].rotacio,1);
|
||||||
|
end;
|
||||||
|
if itocado=0 then aux:=rota_tri(nau,nau.angle,nau.velocitat,1)
|
||||||
|
else tocado;
|
||||||
|
if (aux=1) then begin inc(itocado);aux:=0;end;
|
||||||
|
if bales[1].esta then begin
|
||||||
|
mou_bales(bales[1]);
|
||||||
|
rota_pol(bales[1],0,1);
|
||||||
|
end;
|
||||||
|
waitretrace;
|
||||||
|
volca;
|
||||||
|
{ if aux=1 then begin {gotoxy(0,0);write('tocado')tocado;delay(200);end;}
|
||||||
|
gotoxy(50,24);
|
||||||
|
write('<EFBFBD> Visente i Sergi');
|
||||||
|
gotoxy(50,25);
|
||||||
|
write('<EFBFBD>ETA 2.2 2/6/99');
|
||||||
|
until teclapuls(keyesc);
|
||||||
|
desinstalarkb;
|
||||||
|
ang:=0;
|
||||||
|
repeat waitretrace;rota_pol(pol,ang,0); ang:=ang+0.031415 ;rota_pol(pol,ang,1);until keypressed;
|
||||||
|
text;
|
||||||
|
end.
|
||||||
Reference in New Issue
Block a user