TempleOSTS_130707.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:45:45 +02:00
1 parent 17b71f1a2d
commit 1343005a29
617 files changed
+14399 -25130

No files matched your search

+156
View File
@@ -0,0 +1,156 @@
U0 TanksPlot()
{
Unit *tempu=NULL;
I64 msg_code,p1,p2;
F64 target_x,target_y;
SetViewPlayer(cur_player);
while (TRUE) {
if (!alive_cnt[0] || !alive_cnt[1])
throw(EXCEPT_LOCAL,T_GAME_OVER);
msg_code=GetMsg(&p1,&p2,1<<MSG_KEY_DOWN|
1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
1<<MSG_IP_R_UP);
switch (msg_code) {
case MSG_KEY_DOWN:
HandleChar(p1);
break;
case MSG_IP_L_DOWN:
if (CursorInWindow(Fs,p1,p2)) {
UpdateCursor(Fs,p1,p2);
if (tempu=FindUnit(cursor_row,cursor_col)) {
if (tempu->player==enemy_player || tempu->fired || !tempu->indirect_fire)
tempu=NULL;
else {
RowCol2XY(&fire_radius_x,&fire_radius_y,tempu->row,tempu->col);
fire_radius=tempu->range*2*HEX_RADIUS;
}
}
}
break;
case MSG_IP_L_UP:
if (CursorInWindow(Fs,p1,p2)) {
UpdateCursor(Fs,p1,p2);
RowCol2XY(&target_x,&target_y,cursor_row,cursor_col);
if (!tempu)
Beep;
else {
if (Sqrt(Sqr(fire_radius_x-target_x)+Sqr(fire_radius_y-target_y))>fire_radius)
Beep;
else
PlotShot(tempu,cursor_row,cursor_col);
}
}
tempu=NULL;
fire_radius=0;
break;
case MSG_IP_R_UP:
if (CursorInWindow(Fs,p1,p2))
throw(EXCEPT_LOCAL,T_PHASE_OVER);
break;
}
}
}
U0 TanksMove()
{
Unit *tempu=NULL,*target;
I64 msg_code,p1,p2;
SetViewPlayer(cur_player);
while (TRUE) {
if (!alive_cnt[0] || !alive_cnt[1])
throw(EXCEPT_LOCAL,T_GAME_OVER);
msg_code=GetMsg(&p1,&p2,1<<MSG_KEY_DOWN|
1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
1<<MSG_IP_R_UP);
switch (msg_code) {
case MSG_KEY_DOWN:
HandleChar(p1);
break;
case MSG_IP_L_DOWN:
if (CursorInWindow(Fs,p1,p2)) {
UpdateCursor(Fs,p1,p2);
if (tempu=FindUnit(cursor_row,cursor_col)) {
if (tempu->player==enemy_player || !tempu->remaining_movement)
tempu=NULL;
}
}
break;
case MSG_IP_L_UP:
if (CursorInWindow(Fs,p1,p2)) {
UpdateCursor(Fs,p1,p2);
target=FindUnit(cursor_row,cursor_col);
if (!tempu)
Beep;
else {
if (target)
Beep;
else
MoveUnit(tempu,p1+Fs->horz_scroll.pos,
p2+Fs->vert_scroll.pos);
break;
}
}
tempu=NULL;
break;
case MSG_IP_R_UP:
if (CursorInWindow(Fs,p1,p2))
throw(EXCEPT_LOCAL,T_PHASE_OVER);
break;
}
}
}
U0 TanksFire()
{
Unit *tempu=NULL,*target;
I64 msg_code,p1,p2;
SetViewPlayer(cur_player);
while (TRUE) {
if (!alive_cnt[0] || !alive_cnt[1])
throw(EXCEPT_LOCAL,T_GAME_OVER);
msg_code=GetMsg(&p1,&p2,1<<MSG_KEY_DOWN|
1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
1<<MSG_IP_R_UP);
switch (msg_code) {
case MSG_KEY_DOWN:
HandleChar(p1);
break;
case MSG_IP_L_DOWN:
if (CursorInWindow(Fs,p1,p2)) {
UpdateCursor(Fs,p1,p2);
if (tempu=FindUnit(cursor_row,cursor_col)) {
if (tempu->player==enemy_player || tempu->fired || tempu->indirect_fire)
tempu=NULL;
else {
RVSetUp(cur_player);
RowCol2XY(&fire_radius_x,&fire_radius_y,tempu->row,tempu->col);
fire_radius=tempu->range*2*HEX_RADIUS;
RecalcVisible(RV_ONE_FRIENDLY_UNIT,tempu);
}
}
}
break;
case MSG_IP_L_UP:
if (CursorInWindow(Fs,p1,p2)) {
UpdateCursor(Fs,p1,p2);
target=FindUnit(cursor_row,cursor_col);
if (!tempu)
Beep;
else {
if (!target || target->player!=enemy_player || !Bt(&target->visible,0))
Beep;
else
FireShot(tempu,target);
RecalcVisible(RV_UPDATE_FRIENDLY_UNIT,tempu);
}
}
tempu=NULL;
fire_radius=0;
break;
case MSG_IP_R_UP:
if (CursorInWindow(Fs,p1,p2))
throw(EXCEPT_LOCAL,T_PHASE_OVER);
break;
}
}
}
+77
View File
@@ -0,0 +1,77 @@
Unit *FindNearestUnit(I64 row,I64 col,I64 player,Bool in_LOS,F64 range=-1)
{
I64 i;
F64 d,best_d=MAX_F64,x1,y1,x2,y2;
Unit *best=NULL;
//$LK,"Sqrt","MN:Sqrt"$() is slow, so work with squared distances.
if (range<0)
range=MAX_F64;
else
range*=range;
RowCol2XY(&x1,&y1,row,col);
for (i=0;i<MAX_UNITS;i++)
if (units[player][i].life>0) {
if (!in_LOS || LOS(row,col,units[player][i].row,units[player][i].col)) {
RowCol2XY(&x2,&y2,units[player][i].row,units[player][i].col);
d=Sqr(x2-x1)+Sqr(y2-y1);
if (d<=range && d<best_d) {
best=&units[player][i];
best_d=d;
}
}
}
return best;
}
U0 TanksPlot()
{
Unit *target,*tempu;
I64 i;
for (i=0;i<MAX_UNITS;i++) {
CheckUser;
tempu=&units[cur_player][i];
if (tempu->life>0 && tempu->indirect_fire &&
(target=FindNearestUnit(tempu->row,tempu->col,enemy_player,TRUE,tempu->range*2*HEX_RADIUS)))
PlotShot(tempu,target->row,target->col);
}
throw(EXCEPT_LOCAL,T_PHASE_OVER);
}
U0 TanksMove()
{
Unit *target,*tempu;
I64 i;
F64 x,y;
for (i=0;i<MAX_UNITS;i++) {
CheckUser;
tempu=&units[cur_player][i];
if (tempu->life>0) {
//This cheats because it violates Line-of-Sight
if (target=FindNearestUnit(tempu->row,tempu->col,enemy_player,FALSE)) {
RowCol2XY(&x,&y,target->row,target->col);
if (!MoveUnit(tempu,x,y)) {
RowCol2XY(&x,&y,tempu->row,tempu->col);
MoveUnit(tempu,x+RandI16,y+RandI16);
}
}
}
}
throw(EXCEPT_LOCAL,T_PHASE_OVER);
}
U0 TanksFire()
{
Unit *target,*tempu;
I64 i;
for (i=0;i<MAX_UNITS;i++) {
CheckUser;
tempu=&units[cur_player][i];
if (tempu->life>0 && !tempu->indirect_fire &&
(target=FindNearestUnit(tempu->row,tempu->col,enemy_player,TRUE,tempu->range*2*HEX_RADIUS))) {
FireShot(tempu,target);
Sleep(250*ANIMATION_DELAY);
}
}
throw(EXCEPT_LOCAL,T_PHASE_OVER);
}
+2
View File
@@ -0,0 +1,2 @@
MkDir("HOME/ToTheFront");
+1
View File
@@ -0,0 +1 @@
#include "/TempleOS/Apps/ToTheFront/ToTheFront"
+2
View File
@@ -0,0 +1,2 @@
#include "/TempleOS/Apps/ToTheFront/Load"
ToTheFront;
File diff suppressed because it is too large. Load diff