RE: attn: Ray Smith

new topic     » goto parent     » topic index » view thread      » older message » newer message

Sorry this is a bit long.  I removed a few of the unimportant routines 
to shorten it some.

procedure update_screen()  
	
	blit(back_image, buffer, 1, 1, 1, 1, 1024, 768)           
	if someone_died = 1 then
	  blit(boom_image, buffer, 1, 1, loc_x, loc_y, 100, 100)
	else
	  masked_blit(ship_image, buffer, 1, 1, loc_x, loc_y, 87, 61)
	end if	
	if someone_died = 2 then
	  blit(boom_image, buffer, 1, 1, enemy_loc_x, enemy_loc_y, 100, 100)
	else
	  masked_blit(enemy_image, buffer, 1, 1, enemy_loc_x, enemy_loc_y, 87, 
24)
	end if
	blit(player_status, buffer, 1, 1, 50, 50, player_life, 20)
	blit(enemy_status, buffer, 1, 1, 750, 50, enemy_life, 20)
	blit(buffer, screen_ptr, 1, 1, 1, 1, 1024, 768)  
end procedure

procedure enemy_shoot() -- Enemy shoot routine

	enemy_shotx = enemy_loc_x + 33  
	enemy_shoty = enemy_loc_y + 24
	update_screen()
	line(screen_ptr, enemy_shotx, enemy_shoty, (enemy_shotx - 300), 
enemy_shoty, makecol(200, 0, 0) )
	if loc_x >= (enemy_shotx - 300) and enemy_loc_x >= loc_x then  
		if loc_y <= enemy_shoty and (loc_y + 61) >= enemy_shoty then
			player_life -= 20                                        
			if player_life <= 0 then  
				someone_died = 1 
				update_screen()
				rest(2000)  
			end if                                         
		end if
	end if	
	rest(20)
	update_screen()       

end procedure

procedure fire_laser()  -- Player shoot routine
	shotx = loc_x + 70 -- these guys are for moving the laser start point 
to the actual laser gun
	shoty = loc_y + 53
	update_screen()
	line(screen_ptr, shotx, shoty, (shotx + 300), shoty, 255)  
	if enemy_loc_x <= (shotx + 300) and loc_x <= enemy_loc_x then
		if enemy_loc_y <= shoty and (enemy_loc_y + 24) >= shoty then
			enemy_life -= 20
			if enemy_life <= 0 then
				someone_died = 2  
				update_screen()
				rest(2000)   
			end if		
		end if
	end if
	rest(20)   
	update_screen()	 
end procedure

set_color_depth(32) -- set the color depth to 32 bit  
ret = allegro_init() -- fire up allegro
if ret < 0 then -- if allegro is pooched then 
	allegro_exit()                         -- shut the prog down
	abort(1)                               -- tell windoze that          
end if                                         -- its broke

ret = install_keyboard()  
ret = set_gfx_mode(GFX_AUTODETECT, 1024, 768, 1024, 768)  
ret = install_timer()  
ret = install_int(routine_id("increment_counter"), 100)  

screen_ptr = SCREEN()  

shipPalette = allocate_palette()
set_palette(default_palette() )

buffer = create_bitmap( SCREEN_W(), SCREEN_H() )  
back_image = load_tga("background_2.tga", default_palette() ) 
ship_image = load_tga("soda_cruiser.tga", default_palette() )
enemy_image = load_bitmap("enemy_ship.bmp", default_palette() )
player_status = load_bitmap("player_status.bmp", default_palette() )
enemy_status = load_bitmap("enemy_status.bmp", default_palette() )
boom_image = load_bitmap("boom.bmp", default_palette() )

update_screen()
		
while endflag != 1 and someone_died = 0 do  

	enemy_decision()  

	if key(KEY_UP) then  	
		loc_y -= 8
		if loc_y < 0 then  
			loc_y = 768    
		end if
		update_screen()  

	elsif key(KEY_DOWN) then
		loc_y += 8
		if loc_y > 768 then
			loc_y = 1
		end if
		update_screen()	
		
	elsif key(KEY_RIGHT) then
		loc_x += 8
		if loc_x > 1024 then
			loc_x = 1
		end if
		update_screen()	
		
	elsif key(KEY_LEFT) then
		loc_x -= 8
		if loc_x < 0 then
			loc_x = 1024
		end if
		update_screen()

	elsif key(KEY_SPACE) then
		fire_laser()
		
	elsif key(KEY_ESC) then  
		endflag = 1  
	end if
	
end while



exit_game()

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu