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

Username:   Password: 
 RegisterRegister   
 sniper progam problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Capitano_Canada




PostPosted: Thu Nov 06, 2008 9:07 am   Post subject: 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 Very Happy Canada
Sponsor
Sponsor
Sponsor
sponsor
Capitano_Canada




PostPosted: Thu Nov 06, 2008 9:10 am   Post subject: Re: sniper progam problem

Turing:

%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




PostPosted: Thu Nov 06, 2008 1:15 pm   Post subject: 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




PostPosted: Thu Nov 06, 2008 5:56 pm   Post subject: 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




PostPosted: Thu Nov 06, 2008 7:41 pm   Post subject: 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




PostPosted: Thu Nov 06, 2008 10:49 pm   Post subject: 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




PostPosted: Fri Nov 07, 2008 9:21 am   Post subject: 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




PostPosted: Fri Nov 07, 2008 9:21 am   Post subject: RE:sniper progam problem

wow thnx that makes sooo much sence now i can keep working on my program =D
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Sun Nov 09, 2008 7:33 pm   Post subject: 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




PostPosted: Mon Nov 10, 2008 8:57 am   Post subject: 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




PostPosted: Mon Nov 10, 2008 11:08 am   Post subject: 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




PostPosted: Mon Nov 10, 2008 11:28 am   Post subject: RE:sniper progam problem

i need to var x and y Radius right.. if so what do i verify it as?
ecookman




PostPosted: Mon Nov 10, 2008 11:31 am   Post subject: RE:sniper progam problem

post the script please so i cna copy it and fix it lol


and please the syntax tags
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  [ 13 Posts ]
Jump to:   


Style:  
Search: