Problem with shooting - probably click problem
Author |
Message |
pttptppt
|
Posted: Sat Feb 25, 2017 3:15 pm Post subject: Problem with shooting - probably click problem |
|
|
What is it you are trying to achieve?
When I click, it should fire a blue circle in the direction of the turret (rotated using up/down keys)
What is the problem you are having?
Nothing happens when I click
Describe what you have tried to solve this problem
I've tried redoing the program, and changing variable types and what they're assigned.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
The problematic bit is the Shoot procedure. Everything else works as is supposed to
Turing: |
import GUI
View.Set ("graphics:1500;750, offscreenonly")
var x, y, button : int
var xtemp, ytemp : int := 0
%%%%%%%%%%%%%%%
%Turret Spinning:
var keys : array char of boolean
var tx, ty : real := 0
%Length of Turret:
var realx, realy : real := 0
realx := 60
realy := 60
%%%%%%%%%%%%%%%
procedure draw (x, y : int)
%Scope casing
Draw.FillOval (x, y, 55, 55, black)
Draw.FillOval (x, y, 50, 50, white)
%Thick crosshair threads
Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
Draw.ThickLine (x, y + 50, x, y + 35, 3, black)
%Thin threads
Draw.Line (x - 20, y, x + 20, y, red)
Draw.Line (x, y - 20, x, y + 20, red)
%Adds slight delay. Optional
%delay (100)
end draw
proc rotate
if keys (KEY_UP_ARROW) then
tx := realx
ty := realy
realx := cosd (1) * tx + sind (1) * ty
realy := cosd (1) * ty - sind (1) * tx
end if
if keys (KEY_DOWN_ARROW) then
tx := realx
ty := realy
realx := cosd (1) * tx - sind (1) * ty
realy := sind (1) * tx + cosd (1) * ty
end if
Draw.ThickLine (x, y, x + round (realx ), y + round (realy ), 10, red)
delay (1)
end rotate
var speed : int := 2
var xfinal, yfinal : int
var xv, yv : int
proc shoot
var run, rise : int
var x1, x2, y1, y2 : int
var xtemp, ytemp : int
Mouse.Where (x1, y1, button )
x2 := x1 + round (realx )
y2 := y1 + round (realy )
run := (x2 - x1 )
rise := (y2 - y1 )
var ball : boolean
ball := false
var keys : array char of boolean
if button = 1 then
ball := true
end if
if ball = true then
x2 := x2 + (run div 10)
y2 := y2 + (rise div 10)
drawfilloval (x2, y2, 7, 7, 9)
delay (50)
cls
end if
end shoot
loop
Draw.Cls
Mouse.Where (x, y, button ) %button is a variable that checks if mouse is clicked
draw (x, y )
delay (1)
Input.KeyDown (keys )
rotate
shoot
View.Update
xtemp := x
ytemp := y
end loop
%TO DO!!!:
%Make turret shoot
|
Please specify what version of Turing you are using
Latest |
|
|
|
|
|
Sponsor Sponsor
|
|
|
pttptppt
|
Posted: Sat Feb 25, 2017 3:42 pm Post subject: RE:Problem with shooting - probably click problem |
|
|
EDIT!!! SO I STILL NEED HELP!!! BUT by getting rid of the "cls", the blue circle appears. But it doesn't continue moving which is what i need. It's just a static blue circle
PLS HELP! |
|
|
|
|
|
pttptppt
|
Posted: Sat Feb 25, 2017 3:45 pm Post subject: RE:Problem with shooting - probably click problem |
|
|
OKAY SO i put a loop around the code after "if ball = true then". Problem is the blue dots wont appear until i quit the program.
Help? |
|
|
|
|
|
pttptppt
|
Posted: Sat Feb 25, 2017 4:37 pm Post subject: RE:Problem with shooting - probably click problem |
|
|
Okay i got it to work. But i have a different problem so ill make a new thread |
|
|
|
|
|
|
|