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

Username:   Password: 
 RegisterRegister   
 idea for final grogram
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
starcraft




PostPosted: Mon May 21, 2007 1:13 pm   Post subject: idea for final grogram

Hello.

We just received notice about our final program due in 2 month, and our ideas must be handed in next week. Im a grade 11 student, the final must inculde a randomlizer, delays (moving objects) and its must be in a "game" like manner.

"Maze" like games, the ones where you choose to go left/right are not allowed.

My own idea is a 1 player game called BOWMAN, where you contol a non-moveable Archer to shoot at targets, there will be four targets that is randomly seleceted, each one is different and can have 4 random locations on the console.

In order to shoot, the user must input amount of power and angle on the input console, this will determine if the user actully get a hit, the intergers the user entered will be conpared to a set of my PRE-set interegers, these Pre-set interger are use to determine if the user get a hit or miss.

EXample

target 60 units away, target is a scarcrow.

Pre-set interger, if power =10-20 if angle = 30-45, user hit trager

anything else is miss,

type varables get u into invaild entry.


So, my question is, is this game possible?

If no, are there alternatives?

if yes, what are some of the problems i might have?

Thnak you.
Sponsor
Sponsor
Sponsor
sponsor
cedricb




PostPosted: Mon May 21, 2007 1:45 pm   Post subject: Re: idea for final grogram

you could use an algorithm to determine if the arrow hits the target based on a x and y axis.
to find the distance traveled by the arrow, you need the speed:
S= F * A (where s is speed, N is the force [determined by the user] and A is the acceleration [preset in the program or random])

now you can find the speed of both x and y using:
Sx= S * cos O (where Sx is the speed in x, S is the speed found at the last step and O is the angle)
Sy= S * sin O (where Sy is the speed in y, S is the speed found at the last step and O is the angle)

Now you have Sx which is constant and Sy which varies because of the gravity, you need to find the time that the arrow is in the air:
T = Sy / 4.9 (where Sy is the speed in y)

Now since you have the time, you can check all the points that the tip of the arrow touches using
x = Sx * Ti (where x is the point in the x axis, Sx is the speed of the arrow in the x axis, Ti is the time at one point)
y = (Sy * Ti) - (4.9 * Ti^2) (where y is the point in the y axis, Sy is the speed of the arrow in the y axis, Ti is the time at one point [same as x])


with this algorithm, you'll be able to choose a random position for the target, the shooter and even the acceleration of the arrow.

Note: if you move your shooter, consider his position in x and y and always add them to the last 2 formulas

if you need help to transform these into Java, reply to the thread
starcraft




PostPosted: Mon May 21, 2007 2:27 pm   Post subject: Re: idea for final grogram

Shocked

hmm, i dont get u, i dont know crap about physics.

Its a really simple program, or it should be, just guessing for the right combination of intergers, these's no need for sin or cos.
cedricb




PostPosted: Mon May 21, 2007 4:29 pm   Post subject: Re: idea for final grogram

The only reason why you would want to do it like I said, is it would provide you with real randomization. The whole game would be random and you would have a brand new situation everytime
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: