Shoot help
Author |
Message |
evan467
|
Posted: Thu Feb 18, 2010 11:15 am Post subject: Shoot help |
|
|
Can someone look over this and make the bullets not suck?
setscreen ("graphics: max;max,nobuttonbar")
var boundx1 : int
const maxbullet := 1000
var MaxEnemy : int
var spawnx, spawny : int
var restart : int
var Killcount : int
var movex, movey, x, y, button, personx, persony, personmove : int
var chars : array char of boolean
var run, runcounter, health : int
var shotnum : int
var font : int
var continue : string (1)
font := Font.New ("Arial:20")
var shotcount : int
var cd : int
cd := 0
type Enemy_Type :
record
ex, ey, er, ehealth, spawnx, spawny : real
end record
locate (30, 75)
loop
put "Enter The Amount of Max Enemies"
get MaxEnemy
exit when MaxEnemy > 0
end loop
setscreen ("graphics: max;max,offscreenonly,nobuttonbar")
var Enemy : array 1 .. MaxEnemy of Enemy_Type
type bullet_type :
record
xb, yb, yvelocity, xvelocity, angle, shot : real
end record
var speed : int
speed := 3
var bullet : array 1 .. maxbullet of bullet_type
Killcount := 0
personx := 640
persony := 400
personmove := 0
movex := 0
movey := 0
run := 1
runcounter := 0
shotnum := 1
health := 100
shotcount := 0
loop
for i : 1 .. maxbullet
bullet (i).shot := 0
bullet (i).xb := maxx div 2
bullet (i).yb := maxy div 2
end for
for i : 1 .. MaxEnemy
Enemy (i).spawnx := Rand.Int (0, 3839)
Enemy (i).spawny := Rand.Int (0, 2399)
%
%
Enemy (i).ex := Enemy (i).spawnx
Enemy (i).ey := Enemy (i).spawny
Enemy (i).er := 10
Enemy (i).ehealth := 20
end for
loop
drawfillbox (0, 0, maxx, maxy, grey)
drawfillbox (640 - movex, 2000 - movey, 740 - movex, 300 - movey, black)
drawfillbox (3839 - movex, 1199 - movey, (3839 + 150) - movex, (1199 - 150) - movey, black)
drawfillbox (1 - movex, 1 - movey, 151 - movex, (151) - movey, black) %
drawfillbox (0 - movex, 2400 - movey, 1200 - movex, 2200 - movey, black)
drawfillbox (0 - movex, 2400 - movey, 320 - movex, 1800 - movey, black)
mousewhere (x, y, button)
Input.KeyDown (chars)
if button = 1 and cd = 0 then
if shotcount <= maxbullet then
cd := 1
shotcount += 1
bullet (shotcount).shot := 1
%
if x > maxx div 2 and y > maxy div 2 then
bullet (shotcount).angle := arctand (y - maxy div 2 / x - maxx div 2)
elsif x = maxx div 2 and y > maxy div 2 then
bullet (shotcount).angle := 90
elsif x < maxx div 2 and y > maxy div 2 then
bullet (shotcount).angle := arctand (y - maxy div 2 / maxx div 2 - x)
elsif x < maxx div 2 and y = maxy div 2 then
bullet (shotcount).angle := 180
elsif x < maxx div 2 and y < maxy div 2 then
bullet (shotcount).angle := arctand (maxy div 2 - y / maxx div 2 - x)
elsif x = maxx div 2 and y < maxy div 2 then
bullet (shotcount).angle := 270
elsif x > maxx div 2 and y < maxy div 2 then
bullet (shotcount).angle := arctand (y - maxy div 2 / x - maxx div 2)
elsif x > maxx div 2 and y = maxy div 2 then
bullet (shotcount).angle := 0
%
end if
bullet (shotcount).xvelocity := cosd (bullet (shotcount).angle)
bullet (shotcount).yvelocity := sind (bullet (shotcount).angle)
%
end if
end if
for i : 1 .. maxbullet
if bullet (i).shot = 1 then
bullet (i).xb += bullet (i).yvelocity
bullet (i).yb += bullet (i).xvelocity
if chars (KEY_UP_ARROW) then
bullet (i).yb := bullet (i).yb - run
end if
if chars (KEY_DOWN_ARROW) then
bullet (i).yb := bullet (i).yb + run
end if
if chars (KEY_LEFT_ARROW) then
bullet (i).xb := bullet (i).xb + run
end if
if chars (KEY_RIGHT_ARROW) then
bullet (i).xb := bullet (i).xb - run
end if
drawfilloval (round (bullet (i).xb), round (bullet (i).yb), 1, 1, black)
end if
if bullet (i).xb < 0 or bullet (i).xb > maxx or bullet (i).yb > maxy or bullet (i).yb < 0 then
bullet (i).shot := 0
bullet (i).xb := maxx div 2
bullet (i).yb := maxy div 2
shotcount -= 1
end if
end for
for i : 1 .. MaxEnemy
if Enemy (i).ex > maxx div 2 then
Enemy (i).ex := Enemy (i).ex - Rand.Int (0, 5)
elsif Enemy (i).ex = maxx div 2 then
Enemy (i).ex := Enemy (i).ex
else
Enemy (i).ex := Enemy (i).ex + Rand.Int (0, 5)
end if
if Enemy (i).ey > maxy div 2 then
Enemy (i).ey := Enemy (i).ey - Rand.Int (0, 5)
elsif Enemy (i).ey = maxy div 2 then
Enemy (i).ey := Enemy (i).ey
else
Enemy (i).ey := Enemy (i).ey + Rand.Int (0, 5)
end if
if chars (KEY_UP_ARROW) then
Enemy (i).ey := Enemy (i).ey - run
end if
if chars (KEY_DOWN_ARROW) then
Enemy (i).ey := Enemy (i).ey + run
end if
if chars (KEY_LEFT_ARROW) then
Enemy (i).ex := Enemy (i).ex + run
end if
if chars (KEY_RIGHT_ARROW) then
Enemy (i).ex := Enemy (i).ex - run
end if
drawfilloval (round (Enemy (i).ex), round (Enemy (i).ey), round (Enemy (i).er), round (Enemy (i).er), red)
if Enemy (i).ex < maxx div 2 + 10 and Enemy (i).ex > maxx div 2 - 10 and Enemy (i).ey > maxy div 2 - 10 and Enemy (i).ey < maxy div 2 then
health := health - 1
Font.Draw ("NOM NOM", 640, 420, font, black)
end if
if Enemy (i).ex = maxx div 2 and Enemy (i).ey = maxy div 2 then
health := health - 1
Font.Draw ("NOM NOM", 640, 420, font, black)
end if
for I : 1 .. maxbullet
if bullet (I).shot = 1 and bullet (I).xb < Enemy (i).ex + 10 and bullet (I).xb > Enemy (i).ex - 10 and bullet (I).yb > Enemy (i).ey - 10 and bullet (I).yb < Enemy (i).ey + 10 then
Enemy (i).ehealth := Enemy (i).ehealth - 10
bullet (I).shot := 0
end if
end for
if Enemy (i).ehealth <= 0 then
Enemy (i).ex := Rand.Int (0 - movex, 1917 - movex)
Enemy (i).ey := Rand.Int (0 - movey, 1197 - movey)
Enemy (i).ehealth := 20
Killcount += 1
end if
end for
runcounter := runcounter - 1
if runcounter < 0 then
runcounter := 0
end if
if chars (KEY_UP_ARROW) then
movey := movey + run
end if
if chars (KEY_DOWN_ARROW) then
movey := movey - run
end if
if chars (KEY_LEFT_ARROW) then
movex := movex - run
end if
if chars (KEY_RIGHT_ARROW) then
movex := movex + run
end if
if chars (KEY_ENTER) then
run := 5
runcounter := runcounter + 2
if runcounter > 100 then
run := 0
runcounter := runcounter - 2
end if
else
run := 2
end if
locate (1, 1)
if runcounter > 80 then
run := 1
end if
if maxy * 3 < 1 + movey then
run := 0
movey := movey - 1
end if
if maxx div 2 < 1 - movex then
run := 0
movex := movex + 1
end if
if maxy div 2 < 1 - movey then
run := 0
movey := movey + 1
end if
drawfillbox (0, maxy, 200, maxy - 20, white)
Font.Draw (intstr (runcounter), 0, maxy - 20, font, red)
drawfillbox (50, maxy - 20, 50 + health, maxy, green)
Font.Draw (intstr (Killcount), 150, maxy - 20, font, red)
drawoval (x, y, 10, 10, brightred)
drawline (x + 10, y, x - 10, y, black)
drawline (x, y + 10, x, y - 10, black)
drawfilloval (maxx div 2, maxy div 2, 10, 10, green)
exit when health <= 0
delay (20)
View.Update
personmove := 0
if button = 0 and cd = 1 then
cd := 0
end if
end loop
cls
locate (30, 75)
put "You are losers"
locate (30, 75)
View.Update
getch (continue)
end loop
put "You are suckzorz" |
|
|
|
|
|
Sponsor Sponsor
|
|
|
USEC_OFFICER
|
Posted: Thu Feb 18, 2010 1:01 pm Post subject: RE:Shoot help |
|
|
First: When you want help, comment your program first. It's hard to understand it if you don't comment. You don't have to comment every line, just give a general idea.
Second: You seem to use the arrow keys for moving the bullets. And moving. And moving the enemies. Try to get rid of that or turn them into one block of code.
I'll look at the rest later. |
|
|
|
|
|
SNIPERDUDE
|
Posted: Thu Feb 18, 2010 1:16 pm Post subject: RE:Shoot help |
|
|
Syntax tags help for readability. Here's how!
code: | [syntax="Turing"] code here... [/syntax] |
|
|
|
|
|
|
evan467
|
Posted: Thu Feb 18, 2010 2:39 pm Post subject: Re: Shoot help |
|
|
my apologies and the bullets arent moved by the arrows keys they are affected by movement if yuo run in through the complier itll make more sense, you basically move the world around you in a sense
Turing: |
setscreen ("graphics: max;max,nobuttonbar")
var boundx1 : int
const maxbullet := 1000
var MaxEnemy : int
var spawnx, spawny : int
var restart : int
var Killcount : int
var movex, movey, x, y, button, personx, persony, personmove : int
var chars : array char of boolean
var run, runcounter, health : int
var shotnum : int
var font : int
var continue : string (1)
font := Font.New ("Arial:20")
var shotcount : int
var cd : int
cd := 0
type Enemy_Type :
record
ex, ey, er, ehealth, spawnx, spawny : real
end record
locate (30, 75)
loop
put "Enter The Amount of Max Enemies"
get MaxEnemy
exit when MaxEnemy > 0
end loop
setscreen ("graphics: max;max,offscreenonly,nobuttonbar")
var Enemy : array 1 .. MaxEnemy of Enemy_Type
type bullet_type :
record
xb, yb, yvelocity, xvelocity, angle, shot : real
end record
var speed : int
speed := 3
var bullet : array 1 .. maxbullet of bullet_type
Killcount := 0
personx := 640
persony := 400
personmove := 0
movex := 0
movey := 0
run := 1
runcounter := 0
shotnum := 1
health := 100
shotcount := 0
loop
for i : 1 .. maxbullet
bullet (i ).shot := 0
bullet (i ).xb := maxx div 2
bullet (i ).yb := maxy div 2
end for
for i : 1 .. MaxEnemy
%spawn
Enemy (i ).spawnx := Rand.Int (0, 3839)
Enemy (i ).spawny := Rand.Int (0, 2399)
%
%
Enemy (i ).ex := Enemy (i ).spawnx
Enemy (i ).ey := Enemy (i ).spawny
Enemy (i ).er := 10
Enemy (i ).ehealth := 20
end for
loop
%objects drawns=ings
drawfillbox (0, 0, maxx, maxy, grey)
drawfillbox (640 - movex, 2000 - movey, 740 - movex, 300 - movey, black)
drawfillbox (3839 - movex, 1199 - movey, (3839 + 150) - movex, (1199 - 150) - movey, black)
drawfillbox (1 - movex, 1 - movey, 151 - movex, (151) - movey, black) %
drawfillbox (0 - movex, 2400 - movey, 1200 - movex, 2200 - movey, black)
drawfillbox (0 - movex, 2400 - movey, 320 - movex, 1800 - movey, black)
mousewhere (x, y, button )
Input.KeyDown (chars )
if button = 1 and cd = 0 then
%shot
if shotcount <= maxbullet then
cd := 1
shotcount + = 1
bullet (shotcount ).shot := 1
%PROBLEM AREA Angle+ Velocity Bullet
if x > maxx div 2 and y > maxy div 2 then
bullet (shotcount ).angle := arctand (y - maxy div 2 / x - maxx div 2)
elsif x = maxx div 2 and y > maxy div 2 then
bullet (shotcount ).angle := 90
elsif x < maxx div 2 and y > maxy div 2 then
bullet (shotcount ).angle := arctand (y - maxy div 2 / maxx div 2 - x )
elsif x < maxx div 2 and y = maxy div 2 then
bullet (shotcount ).angle := 180
elsif x < maxx div 2 and y < maxy div 2 then
bullet (shotcount ).angle := arctand (maxy div 2 - y / maxx div 2 - x )
elsif x = maxx div 2 and y < maxy div 2 then
bullet (shotcount ).angle := 270
elsif x > maxx div 2 and y < maxy div 2 then
bullet (shotcount ).angle := arctand (y - maxy div 2 / x - maxx div 2)
elsif x > maxx div 2 and y = maxy div 2 then
bullet (shotcount ).angle := 0
%
end if
bullet (shotcount ).xvelocity := cosd (bullet (shotcount ).angle )
bullet (shotcount ).yvelocity := sind (bullet (shotcount ).angle )
%
end if
end if
for i : 1 .. maxbullet
if bullet (i ).shot = 1 then
bullet (i ).xb + = bullet (i ).yvelocity
bullet (i ).yb + = bullet (i ).xvelocity
if chars (KEY_UP_ARROW) then
bullet (i ).yb := bullet (i ).yb - run
end if
if chars (KEY_DOWN_ARROW) then
bullet (i ).yb := bullet (i ).yb + run
end if
if chars (KEY_LEFT_ARROW) then
bullet (i ).xb := bullet (i ).xb + run
end if
if chars (KEY_RIGHT_ARROW) then
bullet (i ).xb := bullet (i ).xb - run
end if
drawfilloval (round (bullet (i ).xb ), round (bullet (i ).yb ), 1, 1, black)
end if
if bullet (i ).xb < 0 or bullet (i ).xb > maxx or bullet (i ).yb > maxy or bullet (i ).yb < 0 then
bullet (i ).shot := 0
bullet (i ).xb := maxx div 2
bullet (i ).yb := maxy div 2
shotcount - = 1
end if
end for
%enemy movement not perfect yet just basic
for i : 1 .. MaxEnemy
if Enemy (i ).ex > maxx div 2 then
Enemy (i ).ex := Enemy (i ).ex - Rand.Int (0, 5)
elsif Enemy (i ).ex = maxx div 2 then
Enemy (i ).ex := Enemy (i ).ex
else
Enemy (i ).ex := Enemy (i ).ex + Rand.Int (0, 5)
end if
if Enemy (i ).ey > maxy div 2 then
Enemy (i ).ey := Enemy (i ).ey - Rand.Int (0, 5)
elsif Enemy (i ).ey = maxy div 2 then
Enemy (i ).ey := Enemy (i ).ey
else
Enemy (i ).ey := Enemy (i ).ey + Rand.Int (0, 5)
end if
if chars (KEY_UP_ARROW) then
Enemy (i ).ey := Enemy (i ).ey - run
end if
if chars (KEY_DOWN_ARROW) then
Enemy (i ).ey := Enemy (i ).ey + run
end if
if chars (KEY_LEFT_ARROW) then
Enemy (i ).ex := Enemy (i ).ex + run
end if
if chars (KEY_RIGHT_ARROW) then
Enemy (i ).ex := Enemy (i ).ex - run
end if
drawfilloval (round (Enemy (i ).ex ), round (Enemy (i ).ey ), round (Enemy (i ).er ), round (Enemy (i ).er ), red)
if Enemy (i ).ex < maxx div 2 + 10 and Enemy (i ).ex > maxx div 2 - 10 and Enemy (i ).ey > maxy div 2 - 10 and Enemy (i ).ey < maxy div 2 then
health := health - 1
Font.Draw ("NOM NOM", 640, 420, font, black)
end if
if Enemy (i ).ex = maxx div 2 and Enemy (i ).ey = maxy div 2 then
health := health - 1
Font.Draw ("NOM NOM", 640, 420, font, black)
end if
for I : 1 .. maxbullet
if bullet (I ).shot = 1 and bullet (I ).xb < Enemy (i ).ex + 10 and bullet (I ).xb > Enemy (i ).ex - 10 and bullet (I ).yb > Enemy (i ).ey - 10 and bullet (I ).yb < Enemy (i ).ey + 10 then
Enemy (i ).ehealth := Enemy (i ).ehealth - 10
bullet (I ).shot := 0
end if
end for
if Enemy (i ).ehealth <= 0 then
Enemy (i ).ex := Rand.Int (0 - movex, 1917 - movex )
Enemy (i ).ey := Rand.Int (0 - movey, 1197 - movey )
Enemy (i ).ehealth := 20
Killcount + = 1
end if
end for
runcounter := runcounter - 1
if runcounter < 0 then
runcounter := 0
end if
%movement
if chars (KEY_UP_ARROW) then
movey := movey + run
end if
if chars (KEY_DOWN_ARROW) then
movey := movey - run
end if
if chars (KEY_LEFT_ARROW) then
movex := movex - run
end if
if chars (KEY_RIGHT_ARROW) then
movex := movex + run
end if
if chars (KEY_ENTER ) then
%running/faster movement
run := 5
runcounter := runcounter + 2
if runcounter > 100 then
run := 0
runcounter := runcounter - 2
end if
else
run := 2
end if
locate (1, 1)
if runcounter > 80 then
run := 1
end if
if maxy * 3 < 1 + movey then
run := 0
movey := movey - 1
end if
if maxx div 2 < 1 - movex then
run := 0
movex := movex + 1
end if
if maxy div 2 < 1 - movey then
run := 0
movey := movey + 1
end if
drawfillbox (0, maxy, 200, maxy - 20, white)
Font.Draw (intstr (runcounter ), 0, maxy - 20, font, red)
drawfillbox (50, maxy - 20, 50 + health, maxy, green)
Font.Draw (intstr (Killcount ), 150, maxy - 20, font, red)
drawoval (x, y, 10, 10, brightred)
drawline (x + 10, y, x - 10, y, black)
drawline (x, y + 10, x, y - 10, black)
drawfilloval (maxx div 2, maxy div 2, 10, 10, green)
exit when health <= 0
delay (20)
View.Update
personmove := 0
if button = 0 and cd = 1 then
cd := 0
end if
end loop
cls
locate (30, 75)
put "You are losers"
locate (30, 75)
View.Update
getch (continue )
end loop
put "You are suckzorz"
|
|
|
|
|
|
|
USEC_OFFICER
|
Posted: Thu Feb 18, 2010 5:06 pm Post subject: RE:Shoot help |
|
|
The different arrow keys thing just annoys me. (I like everything to be nice and simple) Also thank you for commenting.
Right, lets see...
Drat. I have a program that does almost exactly what you want, but it's at the school. If nobody gives it to you at that time, I'll give it to you. |
|
|
|
|
|
USEC_OFFICER
|
Posted: Thu Feb 18, 2010 10:25 pm Post subject: Re: Shoot help |
|
|
Here we go:
Turing: |
if x > 300 then
angle := arctand (intreal (y - (200)) / intreal (x - (300)))
elsif x < 300 then
angle := arctand (intreal (y - (200)) / intreal (x - (300))) - 180
elsif x = 300 and y > 200 then
angle := 90
elsif x = 300 and y < 200 then
angle := 270
end if
|
The -300/-200 part is the center point. (300,200)
Hope that helps. |
|
|
|
|
|
evan467
|
Posted: Fri Feb 19, 2010 8:10 am Post subject: Re: Shoot help |
|
|
thanks for the help it works now but i did have a super fail if you look it adds the yspeed to the bulletsx and vice versa lol |
|
|
|
|
|
USEC_OFFICER
|
Posted: Fri Feb 19, 2010 12:39 pm Post subject: RE:Shoot help |
|
|
Ha ha ha. Glad I could help. I hope to see the finished verison (Can't spell) when it is done. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Turing_Gamer
|
Posted: Fri Feb 19, 2010 12:42 pm Post subject: Re: Shoot help |
|
|
Wow USEC_OFFICER, you said 'verison' as in the phone company (which may have hidden connections to Bell or Rogers )
I think you meant version. AND NEXT TIME, BEFORE POSTING, LOOK OVER YOUR POST!!! |
|
|
|
|
|
USEC_OFFICER
|
Posted: Fri Feb 19, 2010 12:49 pm Post subject: RE:Shoot help |
|
|
I DO!!!!!!!!!!!!
PLUS I SAID CAN"T SPELL!!!!!!!
AND I YELL ALOT!!!!!!!
BLAR!!!!!!!!!
BLAR IS NOT A WORD!!!!!!
I'll shut up now.
PS. Sorry about ruining this thread with our mindless conversations. |
|
|
|
|
|
SNIPERDUDE
|
Posted: Fri Feb 19, 2010 1:46 pm Post subject: RE:Shoot help |
|
|
There seems to be a few spammish posts around lately. Try to keep some amount of content - we don't need decent threads locked. |
|
|
|
|
|
|
|