

-----------------------------------

Dekkuune

Tue May 22, 2007 4:31 pm


Simulating Gravity/Other Game Help

-----------------------------------

Hello everyone first post  :D ,

I was looking through the Turing example games (the ones you find when you click "Copy Examples" in the "File" drop-down) and they had games that used gravity. 

I've got an ISU due in a few weeks so I thought about replicating the game where you adjust your angle and firepower and things like wind and gravity affect the trajectory of the path of a projectile that you fire (of course, I'm not planning to make AI that fires back, that would require way too much more work  :roll: ) I found that the Pilot game from the Turing Examples has a really nice model for a launched projectile being affected by gravity.

However, I'm finding it difficult to extract from the source how they pulled it off. Anyone know how they did it or any other ways of emulating gravity's effects on a projectile?

Of course, the endeavor mentioned above is mainly secondary project that I'll only complete if I can get some of the things worked out (and if I choose to spend more than 30 mins on this project). My main game is trying to make a High/Low Card game (the dealer shows a card, you guess if the next one will be higher or lower and repeat)

How I plan to approach this program is to have each card represented by the numbers 1-52, aces being low, and then use some boolean operators to check if the card is higher or lower.

I read the FAQ that had a mini guide on efficiently making cards, but I'm still a little confused. Could someone give another explanation? Also since in most versions of the high/low, there is a disregard of the suit, how do I make it so that if both two cards of the same suit are drawn, the result will be a tie? 

I've found a website that a picture of all the cards plus a cardback and I'd like the program to show each respective card as it comes up. How should I go about assigning each card to the respective number efficiently? If I call 3 from the array (which will be the 3 of diamonds), how would I assign that to a picture of the card. A massive [if]if[/i] structure?

Thanks everyone.[/b]


-----------------------------------

Cervantes

Tue May 22, 2007 5:31 pm


RE:Simulating Gravity/Other Game Help

-----------------------------------

For gravity: the simplest thing to do is create an 'object' for your projectile--a collection of variables such as x and y position, and x and y velocities. It's probably best for you to use a record at this point. Check the Turing Walkthrough for a tutorial on records. Now, to move the object, simply apply the velocity to the position each time through your loop. That is, add the x velocity to the x position and likewise for y. To get gravity, all you have to do is subtract (assuming up is positive) a constant factor from your y velocity each time through your loop. No problem!

As for your card game, there are plenty of different ways of dealing with the data. Ultimately, that's all you have. A bunch of data. You want to be able to easily categorize and work with it. Because there are several different approaches, and each has their own advantages and disadvantages, you'll have to make an educated choice as to which approach you use. For your purposes, a 1 dimensional array from 0 to 51 would work fine. Two cards n and m are considered identical (same number value) if the result of dividing n by 4 is the same as the result of dividing m by 4, using integer division.


var n := 13
var m := 14
if floor (n/4) = floor(m/4) then
   put "n and m are the same"
else
   put "n and m are different"
end if



-----------------------------------

Dekkuune

Thu May 24, 2007 3:25 pm


Re: Simulating Gravity/Other Game Help

-----------------------------------

Thanks a ton. It'll take me awhile to get a full grasp on arrays before I go ahead with the records.

However, there's still the problem of efficiently assigning each card picture to each of the random integers and then calling them up whenever they're needed. Is there an easier way than typing out 53 individual Pic.FileNews ?

