Game Development Community

Simple Physics?

by George Fairs · in Torque Game Builder · 11/16/2009 (4:13 pm) · 25 replies

Hello everyone!

I want to start making a VERY simple physics based game that involves balls hitting a bat continuously. How do I make simple physics such as the gravity and the deflection?

This is just a project to help improve my skills, but I am not quite sure where to start.

Thanks.
Page«First 1 2 Next»
#21
11/20/2009 (12:25 pm)
Wow, that's pretty good. It is actually very similar to the game I am trying to make.

For my game (very simple), I want a bat like in pong/breakout and I want ball to increase at increase rate which you must hit enough times to clear the away.

Any ideas how to get the physics for something like that?
#22
11/20/2009 (6:23 pm)
I cant remember. I wasn't playing with the physinc for a long time.
Try copying "loptice" datablocks settings from Datablocks.cs file. ("Loptica" means "small-ball")

The greatest art for me in that project, was to make hole act like that (to "suck" the balls inside)

You will notice that if (you can) to open the game in your editor, the balls on the stage are just flat graphic. I only set them a class. Then i dynamically add them a shadow, and the 3D glow effect, (so the balls get the visual depth) and other physics parameters.

If you are new to TGB, you might also read this:
www.garagegames.com/community/forums/viewthread/106047

Also, try holding the mouse button in my game ;)

You'll just have to experiment until you get desired results.
Here is another topic that explains all physics in TGB:
www.garagegames.com/community/forums/viewthread/95465/1#comment-642349
#23
11/20/2009 (8:14 pm)
Thanks for all this information, and I was wondering whether you'd have to time to 'mentor' me. Quickly I mean, just so I can get in the right direction with torque and torqueScript.

This is only out of curiousity, and whether you're willing to, but I find it much easier to learn from people telling me and helping me along the way rather than written tutorials.

And the hold left click feature is pretty awesome, it's like pool :P

Any more advice?

Thanks... (I just don't know where to start)
#24
11/21/2009 (6:13 am)
I'll give you a tip: always have a 1x1 white pixel image map in your TGB "library". :)
The "line" that shows when you hold the mouse button is actually just one pixel resized to adequate dimensions, and rotated to serve his purpose :)

You can use that "one pixel graphic" for various purposes:
- black out (part of) the screen (just resize it and change his color)
- draw lines
- create basic shapes...

Ok, here is a tip about TGB itself:
- there is "TGB level editor" and "scripting part" of TGB
- The TGB editor is just an interpreter of built in TGB script (in *.cs files)
- The entire TGB level editor is actually built from TGB cript and GUI elements. In earlier versions of TGB you could even modify TGB level editor itself in GUI editor! (that opens with F10) But i suggest you not to mess up with GUI right now coz its really complicated and different from everything else in TGB.
- The 20% (or maybe even less!) of game developing in TGB is done in level editor, the rest is scripting(60%) and creating assets(20%) for your game.
- All script in TGB "starts" from Game.cs file. (you can try to analyse my project code) From there (from startGame() function) you load other external scripts categorized as you like.
- in Datablocks.cs file you create set of attributes for display objects like a templates for objects in your scene.

- As far as for scripting part, TGB was developed in C++ so TGB can chew C++ also! (if you are familiar with it) and the TGB developer created a sets of function and methods that you can apply to the objects.
- EVERYTHING(!) THAT YOU CAN DO IN LEVEL EDITOR - YOU CAN DO THE SAME FROM SCRIPT. The more experienced you get, the more you will use the script.
- Almost EVERY TGB script function MUST be applied to some object and may not be written stand-alone. For eg:
setPostion(10, 10); - this doesn't means anything.
player.setPostion(10, 10); - this means something!
- For errors in your code you have to press "~" while game is running, to open the console. All errors will be listed there.
- Most useful function in entire TGB is probably echo() function (that CAN be written stand-alone) This function prints the message in console. That way you can monitor weather or not some part of your code is executing at all or not (and when). Or you can monitor some variable value this way.
- Bear in mind that all TGB variables are just strings (even numbers!) so writing:
player.setPostion("10", "10"); - this is also legal code
- t2dVector (torque 2D vector) engine is a story of its own. Sometimes the function will pass you a "vector data". The vector data is nothing more than just sets of strings divided with "space".
- Also notice that for every "set" function you have a "get" method. So:
player.getPostion(); - this function will RETURN a "t2dVector"
But you have to "catch" that returning value somehow:
$position = player.getPostion(); - now i store that value in a variable
But to check what really happens "below the hub" you have to:
player.setPostion(10, 10);
$position = player.getPostion();
echo($position) - this will print: 10 10 in the console
- Notice that references to objects (player) don't have prefixes ($,%) that is because they are not variables, those are "links" to individual objects on the stage. You may change objects names during your game, if you want. The same thing is with classes in torque.

- As for the physics... well, you really have to experiment with object properties until you get desirable results.
- Yes, its easier to get direct help from "live people" but you also have to read some documentation or try some tutorials. We all did.

- This is a TGB reference file. It holds the list of (almost-97%) all torque script functions and methods:
webclass.superquest.net/gamemaker-projects/Vickie%20Brown/documentation/referenc...
Keep it open in background while you work.
- You can also briefly read function names in this file, just to get some picture "what you can do" in script.
- Also pay attention what object class are derived from another. That way, t2dSceneObject is class for every graphic object on the stage (you can set its position, rotation, size, layer...) and t2dAnimatedSprite is just another class that "extends" the t2dSceneObject class. This means that Animated Spritea can also use setPosition(), setRotation()... and on top of that they have methods of they own setAnimationFrame() for example. Regular Scene Objects can't use this method of course.

- Don't expect to get any obvious results right away! Game developing is really a hard hard work! (although the product may be entertaining)
#25
11/22/2009 (4:22 pm)
Wow, I don't know what to say. Thanks. I will definitely need to sit down and carefully read through everything you've said, althought I've skim-read it and is clearly going to help.

Thanks for the help everyone

(especially Milan Rancic :D)
Page«First 1 2 Next»