About Store Forum Documentation Contact



Post Reply 
Basic Pong Source?
Author Message
EsentheLaw Offline
Member

Post: #1
Basic Pong Source?
Hey everyone.

I'm still struggling a bit with the engine. I'm also loving it.
I feel a disconnect between code and the world editor. I'm trying to make
a physics based pong with a ball created in the editor.
Now I can't seem to access him in code.
I did watch the "ScarletThreadStudios" tuts on youtube - and others.
Great tuts, but missed the mark for me somehow!

So, anyway, I wonder if anyone has a stripped down basic
physics based pong source project that they may like to share?

I feel like it's sorta the missing tutorial.
I seem to need something simple to pick apart.
I know it's a lot to ask for, but I figured I'd try my luck.
02-11-2015 02:56 AM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #2
RE: Basic Pong Source?
There are a lot of good tutorials for basic objects in the tutorials under geometry (or something like that). For physics pong, you definitely do not need to use the world editor at all. you can just create actors of a ball and two boxes and you will be all set. It would actually be possible in about 10 lines of actual code (other than the Main/Init stuff you need).
02-11-2015 03:32 AM
Find all posts by this user Quote this message in a reply
EsentheLaw Offline
Member

Post: #3
RE: Basic Pong Source?
Thanks!
Yes there is a simple one that shows making ball and cube actor in code.

I said pong to keep it as simple as possible, but I'm actually making an arkanoid.
I would like the editor to layout the bricks for the level. And the ball is a slightly more special object that I want to place inside the editor as well. I've assigned the ball a special physics material as well.

So I shall need to make an object class for my player, then one for bricks - probably more later.
So, if my ObjectClass was Player in code. And the Object in world was a "RoboHead" object. What might some code look like to make an ObjectClass based off the existing instance of RoboHead? Them maybe how would a line of code look like to set this physics object angular velocity for example?
Even more fun, how do I get access to all of my bricks in code? I'd need to know how many, etc.

That's my disconnect. I don't see how to talk to my level objects.
I feel silly, but it just hasn't clicked yet. I suspect that my mind has been to washed by other engines! I'm too blind to see it!

If it helps (everyone's seen arkanoid!) here's a screen shot of what I'm setting up.
It's flat terrain. The RoboHead has a ball body and ball physics material.
https://www.dropbox.com/s/53ulxh2unbrf1l...2.png?dl=0
(Insert image button doesn't work for me..!)

Thanks!
(This post was last modified: 02-11-2015 11:51 AM by EsentheLaw.)
02-11-2015 11:49 AM
Find all posts by this user Quote this message in a reply
Pherael Offline
Member

Post: #4
RE: Basic Pong Source?
First, make class for Brick inherit from Game.Obj (or Game.Static or Game.Kinematic).
In Editor create new Object Class, name it for example OBJ_BRICK.
Set your bricks as OBJ_BRICK.
Then made somewhere in you code(with global acces) Game.ObjMap<Brick> Bricks; <<This is your container with bricks

When you loading world add Game.World.setObjType(Bricks, OBJ_BRICK);

Now using container Bricks you have acces to all loaded in World bricks;
(This post was last modified: 02-11-2015 12:03 PM by Pherael.)
02-11-2015 12:01 PM
Find all posts by this user Quote this message in a reply
EsentheLaw Offline
Member

Post: #5
RE: Basic Pong Source?
Thanks!
I wonder if you could show what it might look like to go thru all bricks and just maybe access or print their x position?
Just so I can see that.


Appreciate all the help so far!
02-12-2015 11:51 AM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #6
RE: Basic Pong Source?
In code file: Brick

Code:
// Inheriting from game static will allow us to use all the functionality from Static objects + add our own functionality
class Brick : Game.Static
{
    virtual void create(Game.ObjParams &obj)
    {
        // If you added custom params in the OBJ, load them here
        // If you don't have any params, you can leave out this entire method

        super.create(obj); // Since we override this method, also call parent's create()
    }

    // Do custom stuff, if needed
}

In code file: Main
Global:

Code:
Game.ObjMap<Brick> Bricks;

In code file: Main
In Init():

Code:
Game.World.activeRange(D.viewRange()).setObjType(Bricks, OBJ_BRICK);

// Rest of world loading.. Check tutorials

To Access the bricks (for example, their position in world space):

In code file: Anywhere

Code:
REPA(Bricks)
{
   Bricks[i].pos(); // Since you are inheriting from Game.Static, you can access all of these methods
}
(This post was last modified: 02-12-2015 12:25 PM by Tottel.)
02-12-2015 12:25 PM
Find all posts by this user Quote this message in a reply
Post Reply