
-----------------------------------
Capitano_Canada
Thu Nov 06, 2008 9:07 am

sniper progam problem
-----------------------------------
kk my problem is were i have the draw fill oval how do i make it so when i click in the oval a bullet hole appears i do know how to make noises when i shoot so you dont have to worry about that lol thnx :D  :canada:

-----------------------------------
Capitano_Canada
Thu Nov 06, 2008 9:10 am

Re: sniper progam problem
-----------------------------------

%Sniper Control Template 
%Created by: Josh Guerette 
%October 29, 2008 
%This template is free to use as long as proper credit is givent to its creator 
View.Set ("graphics, offscreenonly, nobuttonbar") 
drawline (100,200,300,566,white)
var x,y,c:int 
var reload:int 
reload:=0 
var shots_left:int:=40 
var key:array char of boolean 
var alreadyshot:int 

loop 
alreadyshot:=0 
colorback (black) 
Text.Color (white) 
mousewhere (x,y,c) 
%put "x= ",x 
%put "y= ",y 
%put "click= ",c 
View.Update 
cls 
put "Shots Left: ",shots_left 
if c=1 and alreadyshot=0 then 
    shots_left-=1 
    alreadyshot:=1 
    delay (100) 
end if 
if shots_left=0 or shots_left < 0 then 
shots_left:=0 
put "Enter - RELOAD" 
end if 
if shots_left > 40 then 
put "RELOADED" 
shots_left :=10 
end if 

Input.KeyDown (key) 
if key (KEY_ENTER) and shots_left = 0 then 
    shots_left:=40 
    
end if 
drawfilloval (90, 120,60,60,white)
drawoval (x,y,50,50,48) 
drawline (x,y-50,x,y+50,48) 
drawline (x+50,y,x-50,y,48) 
drawbox (x-5,y+5,x+5,y-5,brightred) 





end loop 



oops lol here is the program

-----------------------------------
pavol
Thu Nov 06, 2008 1:15 pm

Re: sniper progam problem
-----------------------------------
Depending on if you want the bullet holes to stay forever or just one at a time and then disappear...or if you want them to stay until you reload, you will have to then store the x and y positions of each bullet hole in a variable, preferably an array if you have more appearing at once, and then redraw them every time just like you redraw the crosshair.

-----------------------------------
Ledrif
Thu Nov 06, 2008 5:56 pm

RE:sniper progam problem
-----------------------------------
How would you array multiple draws?
I would guess make the array changing the variable of the x and y midpoints.

I am trying to figure out the coding of this myself aswell however im having difficulty, I had given up and simply am now trying to see if it would work removing the CLS, and simply redraw my moving shape with the background colour. To keep my multiple draws.

-----------------------------------
The_Bean
Thu Nov 06, 2008 7:41 pm

Re: sniper progam problem
-----------------------------------
An easy way of doing it would be with a flexible array.

var xHole, yHole : flexible array 1..0 of int 
We have 2 variables x and y for the center of the hole, and when we declare it, we say 1..0 because there are currently no holes at the beginning.

When the user clicks on the screen you now have a shot and a new bullet hole.
inside the if statement for checking when a bullet is fired we have to add a new hole to the array of holes
This is done by:
new xHole , xHole (upper (xHole)) + 1
new yHole , yHole (upper (yHole)) + 1
upper () is used to find the current upper boundary of the array and we add 1 to increase the upper boundary by 1

then still inside the if statement assign these new variables a value

xHole (upper (xHole)) := Mouse x
yHole (upper (yHole)) := Mouse y

then to draw these bullet holes we need a for statement
put it after you draw the white hole of the viewing area

for i : 1 .. upper(xHole)
  Draw.Oval(xHole(i),yHole(i),xRadius,yRadius,colour)
end for

-----------------------------------
Ledrif
Thu Nov 06, 2008 10:49 pm

RE:sniper progam problem
-----------------------------------
Ah, so as action occurs(shoot,collision,click,move),increase the value then assign the array value to the location.
The for statement makes it so that for each array value you draw a independent shape.

That example will help me out alot, the turing help referance of flexable arrays is kinda, haha.

-----------------------------------
ecookman
Fri Nov 07, 2008 9:21 am

RE:sniper progam problem
-----------------------------------
yes it works

p.s i am working on the program with capitano_Canada

please use code tags makkes it easier to read but tyvm

-----------------------------------
Capitano_Canada
Fri Nov 07, 2008 9:21 am

RE:sniper progam problem
-----------------------------------
wow thnx that makes sooo much sence now i can keep working on my program =D

-----------------------------------
SNIPERDUDE
Sun Nov 09, 2008 7:33 pm

RE:sniper progam problem
-----------------------------------
Just for a quick note - Sniper rifles don't shoot that fast, use some sort of a delay system for between shots (that doesn't pause the entire programme)

-----------------------------------
ecookman
Mon Nov 10, 2008 8:57 am

RE:sniper progam problem
-----------------------------------
lol ya it is a semi auto...if you want single fire click quickly


and help don't hinder

-----------------------------------
Capitano_Canada
Mon Nov 10, 2008 11:08 am

RE:sniper progam problem
-----------------------------------
oh ya sry about that i changed it because there was no delay so you had to click really fast to only shoot once but i will ad that later

-----------------------------------
Capitano_Canada
Mon Nov 10, 2008 11:28 am

RE:sniper progam problem
-----------------------------------
i need to var x and y Radius right.. if so what do i verify it as?

-----------------------------------
ecookman
Mon Nov 10, 2008 11:31 am

RE:sniper progam problem
-----------------------------------
post the script please so i cna copy it and fix it lol


and please the syntax tags
