home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: Shareware for Win 95
/
Chip-Shareware-Win95.bin
/
grafika
/
formula
/
killmain.sx_
/
killmain.sx
Wrap
Text File
|
1995-08-28
|
4KB
|
167 lines
/////////////////////////////////////////
// KILL MUNGER The demo game
/////////////////
start:
mouse mode OFF
call init_bitmaps
call init_sounds
badass = new script "killbdss.sxt"
badass call initialize: @badass_bitmaps
smx,smy = GRAPHICS_XMAX/2,GRAPHICS_YMAX/2
mouse position smx,smy
badass call draw_frame
bmx,bmy = smx,smy
badass call update_pos: bmx,bmy
fire_scripts = new list
fire_sprites = new list
soldier_scripts = new list
soldier_sprites = new list
time = TIME
soldier_time = TIME
win_message = 0
while win_message != WM_KEYDOWN
peekmessage win_message, wpm, pmx, pmy
switch win_message
case WM_LBUTTONDOWN
play sound shoot rate shoot_rate
call fire_gun
case WM_MOUSEMOVE
mx = pmx - smx
my = pmy - smy
if mx || my
bmx = bmx + mx
bmy = bmy + my
mouse position smx,smy
if TIME > time + 5
for n = fire_scripts.size - 1 to 0 step -1
shot_script = fire_scripts get n
k = shot_script call update_fire
if k
fire_scripts remove n
fire_sprites remove n
free shot_script
free shot_sprite
t = bound bmx,bmy to 0,GRAPHICS_XMAX; 0,GRAPHICS_YMAX mode CLIP
badass call update_pos: bmx,bmy
nx = soldier_sprites.size - 1
for n = nx to 0 step -1
soldier = soldier_scripts get n
soldier call update_pos
soldite = soldier_sprites get n
tst = collision EXTERNAL sprite soldite
if tst
for m = fire_sprites.size-1 to 0 step -1
shot_sprite = fire_sprites get m
tst = collision EXTERNAL sprite soldite sprite shot_sprite
if tst
soldier_scripts remove n
soldier_sprites remove n
play sound explode rate explode_rate
fire = fire_scripts get m
fire call blast
//free fire
break
free shot_sprite
free soldier
free soldite
time = TIME
if TIME > soldier_time + 150 && soldier_scripts.size < 6
soldier = new script "killsold.sxt"
soldite = soldier call initialize: @soldier_bitmaps
soldier_scripts add soldier
soldier_sprites add soldite
soldier call draw_frame
free soldier
free soldite
soldier_time = TIME
update sprites
mouse mode ON
return
fire_gun:
x,y,ix,iy = badass call shoot
shot_script = new script "killfire.sxt"
shot_sprite = shot_script call initialize: @fire_bitmaps,x,y,ix,iy
fire_scripts add shot_script
fire_sprites add shot_sprite
free shot_script
free shot_sprite
///////////////////////////////////
// INITIALIZATIONS
/////////////
init_bitmaps:
bitmap_list = new list
palette_list = new list
files = new byte[10][32]
$files[0] = "ball_red";"ball_grn";"ball_blu";""
soldier_bitmaps = call load_bitmaps
$files[0] = "km_shot";"km_exp";"km_dust";""
fire_bitmaps = call load_bitmaps
$files[0] = "km_ball";"km_f1";"km_f2";""
badass_bitmaps = new list
bl1 = call load_bitmaps
badass_bitmaps add bl1
call remap_palettes
bl2 = new list
call mirror_bitmaps: @bl1, @bl2
badass_bitmaps add bl2
/////////////////////////
init_sounds:
load "shoot.wav" sound shoot rate shoot_rate
load "explode.wav" sound explode rate explode_rate
//////////////////////////
load_bitmaps:
return_list = new list
for n = 0 to 9
if files[n][0] == 0
break
load $files[n], ".gif" bitmap bmp palette pal
return_list add bmp
bitmap_list add bmp
palette_list add pal
return @return_list
///////////////////////////
mirror_bitmaps: list1, list2
for n = 0 to list1.size-1
bm1 = list1 get n
copy bm2 = bm1
flip HORIZONTAL bitmap bm2
list2 add bm2
/////////////////////////
remap_palettes:
for n = 0 to bitmap_list.size-1
pal = palette_list get n
compose palette pal
for n = 0 to bitmap_list.size-1
bmp = bitmap_list get n
pal = palette_list get n
remap bitmap bmp palette pal
///////////////////////////
/////////////////////