Gunbound
Author |
Message |
BenLi
|
Posted: Wed Apr 26, 2006 3:58 pm Post subject: Gunbound |
|
|
Hey ppl, this is the start to a gunbound like game,
i've only completed the essentials, haven't built a game around it yet
check it out and suggestions will be welcome
code: |
setscreen ("graphics:800;600,offscreenonly")
%const detail := 10
var speed : int := 0
const startx := 0
const starty := 0
var shotx, shoty : real
var mx, my, mb : int
var deltax, deltay : real
var b : real
var ang : real
var grav := 0
var starttime, endtime : int
var counter : real := 0
loop
shotx := startx
shoty := starty
loop
mousewhere (mx, my, mb)
b := Math.Distance (startx, starty, mx, my)
deltay := my - starty
deltax := mx - startx
ang := arcsind (deltay / b)
if mx < startx then
ang := 180 - ang
end if
locate (1, 1)
put "Angle is: ",ang
View.Update
exit when mb = 1
end loop
grav := 0
deltay := my - starty
deltax := mx - startx
counter := 0
b := Math.Distance (startx, starty, mx, my)
ang := arcsind (deltay / b)
if mx < startx then
ang := 180 - ang
end if
loop
mousewhere (mx, my, mb)
exit when mb = 1
end loop
starttime := Time.Elapsed
loop
mousewhere (mx, my, mb)
counter += 1.5
locate (2, 1)
put "POWER: ", counter
drawfillbox (0, 0, round (counter * 8), 25, brightblue)
drawfillbox (0, 8, round (counter * 8), 17, blue)
drawfilloval (0, 0, 5, 5, white)
drawfilloval (0, 25, 5, 5, white)
drawfilloval (round (counter * 8), 0, 5, 5, white)
drawfilloval (round (counter * 8), 25, 5, 5, white)
View.Update
exit when mb = 0 or counter >= 100
end loop
endtime := Time.Elapsed
speed := round ((endtime - starttime) / 25)
loop
shotx := shotx + (deltax / ((Math.Distance (startx, starty, mx, my)) / speed))
shoty := shoty + (deltay / ((Math.Distance (startx, starty, mx, my)) / speed))
grav := grav + 2
shoty := shoty - grav
drawfilloval (round (shotx), round (shoty), 10, 10, red)
View.Update
cls
put "Angle is: ", ang
exit when shoty < -10
end loop
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
xHoly-Divinity
|
Posted: Wed Apr 26, 2006 4:09 pm Post subject: (No subject) |
|
|
Might want to add something to slow down the power bar (when u click the mouse). Delay might not be the best solution but it works. |
|
|
|
|
|
BenLi
|
Posted: Wed Apr 26, 2006 4:13 pm Post subject: (No subject) |
|
|
well im trying to model it from gunbound,so the delay thing is accurate, but i think i should use button initiation instead of mouse |
|
|
|
|
|
HellblazerX
|
Posted: Wed Apr 26, 2006 8:30 pm Post subject: (No subject) |
|
|
about this portion of code:
code: | shotx := shotx + (deltax / ((Math.Distance (startx, starty, mx, my)) / speed))
shoty := shoty + (deltay / ((Math.Distance (startx, starty, mx, my)) / speed)) |
before calculating shotx and shoty, make sure that the variable speed is not 0, and that the Distance between the 2 points is not 0, cuz otherwise you'll run into the problem of dividing by 0. b/c i ran into that problem when running your program. And that power bar goes way too fast. |
|
|
|
|
|
xHoly-Divinity
|
Posted: Thu Apr 27, 2006 3:51 pm Post subject: (No subject) |
|
|
Nahhh, no way it's that fast in gunbound. Oh well, ur choice. Yeah, I would make it using button initiation, probably the space bar. |
|
|
|
|
|
TokenHerbz
|
Posted: Thu Apr 27, 2006 7:01 pm Post subject: (No subject) |
|
|
what's so special about that "math." feature... i dont have it and all the games that USE it i cant run
Making your own mathimatical proceadures is much better for througly understanding how things work, and at least this way, people like me can play the code
**asks for the Math. fcn to add to his turing lib**
(just pm me with it, and instructions please )
/me waits for smart cervantes to hook him up |
|
|
|
|
|
codemage
|
Posted: Fri Apr 28, 2006 8:56 am Post subject: (No subject) |
|
|
I think Turing 4.0.3 is missing the Math functions. |
|
|
|
|
|
Andy
|
Posted: Fri Apr 28, 2006 9:47 am Post subject: (No subject) |
|
|
if you indeed go to massey, then i think i know who you are.. anywho, ask mr.mckenzie about the gunbound shawnli and shane li made 2 years ago. he should still have it. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
BenLi
|
Posted: Sat Apr 29, 2006 9:53 am Post subject: (No subject) |
|
|
Andy Sun?
Andyeah, i took grade 10 compsci, big mistake, anyways, i'll ask mr mac |
|
|
|
|
|
wtd
|
Posted: Sat Apr 29, 2006 1:20 pm Post subject: (No subject) |
|
|
HellblazerX wrote: about this portion of code:
code: | shotx := shotx + (deltax / ((Math.Distance (startx, starty, mx, my)) / speed))
shoty := shoty + (deltay / ((Math.Distance (startx, starty, mx, my)) / speed)) |
before calculating shotx and shoty, make sure that the variable speed is not 0, and that the Distance between the 2 points is not 0, cuz otherwise you'll run into the problem of dividing by 0. b/c i ran into that problem when running your program. And that power bar goes way too fast.
And factor out this:
code: | ((Math.Distance (startx, starty, mx, my)) / speed) |
As it stands, you're calculating the same exact value twice for no good reason. |
|
|
|
|
|
Cervantes
|
Posted: Sat Apr 29, 2006 4:24 pm Post subject: (No subject) |
|
|
TokenHerbz wrote:
**asks for the Math. fcn to add to his turing lib**
(just pm me with it, and instructions please )
/me waits for smart cervantes to hook him up
This question is asked far too often. Search around a bit. There's even a tutorial on this very subject! |
|
|
|
|
|
BenLi
|
Posted: Sun Apr 30, 2006 4:10 pm Post subject: (No subject) |
|
|
well right the power bar and shot relies entiredly on the speed the computer loops, im working on a system to make it the same on every comp |
|
|
|
|
|
Andy
|
Posted: Tue May 02, 2006 12:33 pm Post subject: (No subject) |
|
|
use a timer instead of delay |
|
|
|
|
|
|
|