Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Bullet makes enemy dissipear help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bluebomb




PostPosted: Thu Dec 15, 2011 4:51 pm   Post subject: Bullet makes enemy dissipear help

I want to make it where when the bullet hits the enemy, the enemy dissipears completely
Help would be appriected.
Here's my code:

View.Set ("offscreenonly")
Window.Set (defWinID, "graphics:1010;650")
colourback (green)
var x, y, x1, y1 : int
var playerX := maxx div 2
var playerY := 10
var mouseX, mouseY, mouseB : int := 0
var shotangle : real
var bulletX, bulletY, bulletVarX, bulletVarY : real := 0
var bulletDead : boolean := true
var chars : array char of boolean
var playerStep := 5
var enemyStep : real := 0.1
var wallPic : int
var blocker : boolean
var path1X : real := 25
var path1Y : real := maxy - 8
var path2X : real := 85
var path2Y : real := maxy - 8
var path3X : real := 175
var path3Y : real := maxy - 8
var path4X : real := 375
var path4Y : real := maxy - 8
var path5X : real := 450
var path5Y : real := maxy - 8
var path6X : real := 475
var path6Y : real := maxy - 8
var path7X : real := 550
var path7Y : real := maxy - 8
var path8X : real := 800
var path8Y : real := maxy - 8
var path9X : real := 885
var path9Y : real := maxy - 8
var path10X : real := maxx - 25
var path10Y : real := maxy - 8
var basicSoldiers : array 1 .. 10 of int

%Pre-Set AI Paths

procedure path1
path1Y -= enemyStep
end path1

procedure path2
if round (path2Y) > 325 then
path2Y -= enemyStep
elsif round (path2Y) = 325 then
path2X += enemyStep
end if
if round (path2X) = 150 then
path2Y -= enemyStep
end if
end path2

procedure path3
path3Y -= enemyStep
end path3

procedure path4
if round (path4Y) > 200 then
path4Y -= enemyStep
elsif round (path4Y) = 200 then
path4X -= enemyStep
end if
if round (path4X) = 350 then
path4Y -= enemyStep
end if
end path4

procedure path5
if round (path5Y) > 450 then
path5Y -= enemyStep
elsif round (path5Y) = 450 then
path5X -= enemyStep
end if
if round (path5X) = 350 then
path5Y -= enemyStep
end if
end path5

procedure path6
if round (path6Y) > 350 then
path6Y -= enemyStep
elsif round (path6Y) = 350 then
path6X += enemyStep
end if
if round (path6X) = 575 then
path6Y -= enemyStep
end if
end path6

procedure path7
path7Y -= enemyStep
end path7

procedure path8
path8Y -= enemyStep
end path8

procedure path9
if round(path9Y)>325 then
path9Y-=enemyStep
elsif round(path9Y)=325 then
path9X-=enemyStep
end if
if round(path9X)=750 then
path9Y-=enemyStep
end if
end path9

procedure path10
path10Y -= enemyStep
end path10

%Enemy Spawn Procedures

procedure basicSoldier1
for i : 1 .. 10
if path1Y > 0 then
drawfilloval (round (path1X), round (path1Y), 8, 8, brightred)
path1
end if
end for
end basicSoldier1

procedure basicSoldier2
for i : 1 .. 10
if path2Y > 0 then
drawfilloval (round (path2X), round (path2Y), 8, 8, brightred)
path2
end if
end for
end basicSoldier2

procedure basicSoldier3
for i : 1 .. 10
if path3Y > 0 then
drawfilloval (round (path3X), round (path3Y), 8, 8, brightred)
path3
end if
end for
end basicSoldier3

procedure basicSoldier4
for i : 1 .. 10
if path4Y > 0 then
drawfilloval (round (path4X), round (path4Y), 8, 8, brightred)
path4
end if
end for
end basicSoldier4

procedure basicSoldier5
for i : 1 .. 10
if path5Y > 0 then
drawfilloval (round (path5X), round (path5Y), 8, 8, brightred)
path5
end if
end for
end basicSoldier5

procedure basicSoldier6
for i : 1 .. 10
if path6Y > 0 then
drawfilloval (round (path6X), round (path6Y), 8, 8, brightred)
path6
end if
end for
end basicSoldier6

procedure basicSoldier7
for i : 1 .. 10
if path7Y > 0 then
drawfilloval (round (path7X), round (path7Y), 8, 8, brightred)
path7
end if
end for
end basicSoldier7

procedure basicSoldier8
for i : 1 .. 10
if path8Y > 0 then
drawfilloval (round (path8X), round (path8Y), 8, 8, brightred)
path8
end if
end for
end basicSoldier8

procedure basicSoldier9
for i : 1 .. 10
if path9Y > 0 then
drawfilloval (round (path9X), round (path9Y), 8, 8, brightred)
path9
end if
end for
end basicSoldier9

procedure basicSoldier10
for i : 1 .. 10
if path10Y > 0 then
drawfilloval (round (path10X), round (path10Y), 8, 8, brightred)
path10
end if
end for
end basicSoldier10

%Main Game Loop

loop
%Enemy Spawns

basicSoldier1
basicSoldier2
basicSoldier3
basicSoldier4
basicSoldier5
basicSoldier6
basicSoldier7
basicSoldier8
basicSoldier9
basicSoldier10

%Generate map obstacles

wallPic := Pic.FileNew ("brick_tex.jpg")
Pic.Draw (wallPic, maxx - 560, maxy - 400, picCopy)
Pic.Draw (wallPic, maxx - 960, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 820, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 760, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 620, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 562, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 400, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 340, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 190, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 130, maxy - 550, picCopy)
Pic.Draw (wallPic, maxx - 945, maxy - 400, picCopy)
Pic.Draw (wallPic, maxx - 160, maxy - 400, picCopy)
Pic.Draw (wallPic, maxx - 360, maxy - 350, picCopy)
Pic.Draw (wallPic, maxx - 360, maxy - 290, picCopy)
Pic.Draw (wallPic, maxx - 360, maxy - 230, picCopy)
Pic.Draw (wallPic, maxx - 360, maxy - 170, picCopy)
Pic.Draw (wallPic, maxx - 423, maxy - 170, picCopy)
Pic.Draw (wallPic, maxx - 790, maxy - 170, picCopy)
Pic.Draw (wallPic, maxx - 727, maxy - 170, picCopy)
Pic.Draw (wallPic, maxx - 790, maxy - 233, picCopy)
Pic.Draw (wallPic, maxx - 790, maxy - 280, picCopy)
Pic.Draw (wallPic, maxx - 790, maxy - 343, picCopy)

%Mouse commands

Mouse.Where (mouseX, mouseY, mouseB)
if mouseX = playerX and mouseY > playerY then
shotangle := 270
elsif mouseX < playerX and mouseY = playerY then
shotangle := 0
elsif mouseX = playerX and mouseY < playerY then
shotangle := 90
elsif mouseX > playerX and mouseY = playerY then
shotangle := 180
elsif mouseX > playerX then
shotangle := arctand ((mouseY - playerY) / (mouseX - playerX)) + 180
else
shotangle := arctand ((mouseY - playerY) / (mouseX - playerX))
end if

if mouseB = 1 and bulletDead = true then
bulletDead := false
bulletX := playerX - (40 * cosd (shotangle))
bulletY := playerY - (40 * sind (shotangle))
bulletVarX := -5 * cosd (shotangle)
bulletVarY := -5 * sind (shotangle)
end if

%Player commands

Draw.FillOval (playerX, playerY, 8, 8, blue)
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) and whatdotcolor (playerX, playerY + 9) = 2 then
playerY += playerStep
end if
if chars (KEY_DOWN_ARROW) and whatdotcolor (playerX, playerY - 9) = 2 then
playerY -= playerStep
end if
if chars (KEY_LEFT_ARROW) and whatdotcolor (playerX - 9, playerY) = 2 then
playerX -= playerStep
end if
if chars (KEY_RIGHT_ARROW) and whatdotcolor (playerX + 9, playerY) = 2 then
playerX += playerStep
end if
if playerX < 8 then
playerX := 8
end if
if playerY < 8 then
playerY := 8
end if
if playerX > (maxx - 8) then
playerX := (maxx - 8)
end if
if playerY > (maxy - 8) then
playerY := (maxy - 8)
end if

%Player Shooting

if bulletDead = false then
Draw.FillOval (round (bulletX), round (bulletY), 2, 2, 14)
bulletX += bulletVarX
bulletY += bulletVarY
if bulletX > maxx or bulletX < 0 or bulletY > maxy or bulletY < 0 or blocker = true then
bulletDead := true
end if
end if
if whatdotcolor (round (bulletX), round (bulletY)) = 2 then
blocker := false
else
blocker := true
end if

if bulletX + 8 = brightred then
exit

end if
if bulletY - 8 = brightred then
exit

end if

Pic.Free (wallPic)
View.Update
cls
end loop
Sponsor
Sponsor
Sponsor
sponsor
Aange10




PostPosted: Thu Dec 15, 2011 5:29 pm   Post subject: RE:Bullet makes enemy dissipear help

Quote:
I want to make it where when the bullet hits the enemy, the enemy dissipears completely
Help would be appriected.
Here's my code:


This is the format they give you? Interesting!

Here is the answer!:





.... Ooops, I deleted my answer format.
Dreadnought




PostPosted: Thu Dec 15, 2011 9:40 pm   Post subject: Re: Bullet makes enemy dissipear help

Like Aange10 said, please fill out the form (properly).

I will answer in a question (in your style).

How do you make it where when the bullet hits stuff it disappears completely?
evildaddy911




PostPosted: Fri Dec 16, 2011 11:31 am   Post subject: Re: Bullet makes enemy dissipear help

use the search bar at the top to see if anyone has asked the same question
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: