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

Username:   Password: 
 RegisterRegister   
 Help with Avalanche Game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Shinkei




PostPosted: Wed Apr 27, 2011 1:08 am   Post subject: Help with Avalanche Game

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
I want to make an avalanche game where objects fall down(preferably triangles) and hit the player(in this case it is a cube).
I need help on collision detection as well as objects falling randomly.


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
4.11
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Wed Apr 27, 2011 7:38 am   Post subject: RE:Help with Avalanche Game

Well, then you'll need two things:
1. Arrays
2. Input.KeyDown
Ever used either of those?
Shinkei




PostPosted: Wed Apr 27, 2011 7:42 am   Post subject: RE:Help with Avalanche Game

I have Input.KeyDown for the character
But I have no clue about the falling objects.
Raknarg




PostPosted: Wed Apr 27, 2011 9:01 am   Post subject: Re: Help with Avalanche Game

Well, I'll try to give you a brief overview of them, but I would suggest looking up the Turing Tutorial in the Tutorial section.
So arrays are essentially single variables that can hold more than one piece of information. Imagine it like a box with a bunch of different compartments inside. You call it like this:
Turing:

var thingy : array 1 .. 5 of int

Those numbers can be set to anything, as well as the identifier. You could have an array of chars, strings, reals, nats, or even procedures if you wanted.
Falling objects are rather simple. I'll give you a code snippet:
Turing:

setscreen ("offscreenonly")
var objectx, objecty : array 1 .. 5 of int

for i : 1 .. 5
    objectx (i) := Rand.Int (0, maxx)
    objecty (i) := Rand.Int (0, maxy)
end for

loop
    for i : 1 .. 5
        objecty (i) := objecty (i) - 1
        if objecty (i) < 0 then
            objecty (i) := maxy
            objectx (i) := Rand.Int (0, maxx)
        end if
        Draw.FillOval (objectx (i), objecty (i), 5, 5, 7)
    end for
    View.Update
    delay (5)
    cls
end loop

All you would have to to is have the objects constantly falling, and reset their x and y positions when they hit the ground.
FYI in case you didn't know, to access a certain element within an array, you call the variable name and a number.
ex:
Turing:

var foo : array 1 .. 3 of int
foo (1) := 3
put foo (1)

So that way you can set variables inside the array. However, you can do this simply using a for loop, too!
Turing:

var foo : array 1 .. 5 of int
for i : 1 .. 5
     foo (i) := i * i
end for
for j : 1 .. 5
     put foo (i)
end for

This code would have an output of:
1
4
9
16
25
Anyways, hope that helps.
Again, check the actual tutorial for more info.
apython1992




PostPosted: Wed Apr 27, 2011 1:37 pm   Post subject: RE:Help with Avalanche Game

If you understand how to get certain properties about an object (position, length, width, etc), then collision detection will be a piece of cake.
Raknarg




PostPosted: Wed Apr 27, 2011 3:36 pm   Post subject: RE:Help with Avalanche Game

He could just use Math.Distance instead. Wish I knew about that earlier.
Of course, thats only good for certain kinds of collision...
apython1992




PostPosted: Wed Apr 27, 2011 3:38 pm   Post subject: RE:Help with Avalanche Game

Ahh. I don't know Turing, but yes, that would be helpful.
Raknarg




PostPosted: Wed Apr 27, 2011 3:56 pm   Post subject: RE:Help with Avalanche Game

All I know is turing. C++ is too much work ;P
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Wed Apr 27, 2011 3:59 pm   Post subject: RE:Help with Avalanche Game

Slightly off-topic, but Raknarg, why not learn C? You need to (read: should) learn it before C++ anyway, and it's fairly similar to Turing mechanics-wise. Not a hard language at all to learn.
apython1992




PostPosted: Wed Apr 27, 2011 4:00 pm   Post subject: RE:Help with Avalanche Game

I don't really enjoy C++ a whole lot. I use it only when I need fast code. And sometimes when I need fast code I still don't use it Razz
Raknarg




PostPosted: Wed Apr 27, 2011 4:04 pm   Post subject: Re: Help with Avalanche Game

Thats what Turing is for Very Happy

c:

#include <iostream>
int.main;
{
     cout << "C++ is meh." << endl;
     cin ();
}

or...
Turing:

put "Turing. Yay."
apython1992




PostPosted: Wed Apr 27, 2011 4:52 pm   Post subject: RE:Help with Avalanche Game

I agree with Insectoid. The more languages you learn the better. You seem to understand Turing well enough, why not move on? Yes, C++ has an ugly "Hello, world" program, but it outdoes Turing in many more ways. Or, if you'd rather not dive in to a lower-level language quite yet, I would strongly suggest Python or Ruby.
Raknarg




PostPosted: Wed Apr 27, 2011 7:59 pm   Post subject: RE:Help with Avalanche Game

Yeah, I'm starting to begin other stuff... After playing around with my now rediculously complex space game, I realize that Turing can be really slow Razz I just recently got C++, and I'm starting Ruby. But this can continue somewhere else, I'm sure the OP doesn't need an insight in my life Razz
Ev4n




PostPosted: Sat Dec 08, 2012 7:17 pm   Post subject: RE:Help with Avalanche Game

I have the balls spawning at random now how can i make let's say a red one spawn randomly but make it very rare (power-up_
Panphobia




PostPosted: Sat Dec 08, 2012 7:29 pm   Post subject: RE:Help with Avalanche Game

Ev4n @ Sat Dec 08, 2012 7:17 pm wrote:
I have the balls spawning at random now how can i make let's say a red one spawn randomly but make it very rare (power-up_

make your own thread, with the proper format
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  [ 15 Posts ]
Jump to:   


Style:  
Search: