May 22, 2012, 05:36:09 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: A really simple example please  (Read 2421 times)
Tiles
Full Member
***
Posts: 135



View Profile WWW
« on: October 04, 2008, 05:38:25 AM »

Still stuck in the basics. And so i look for examples to learn from. Problem is, there isn't really lots of choice. There is even not this much beginner stuff. Currently we have four more or less complete games. Basic multiplayer, Chess, Marble game and Spaceshooter. They are too big for a beginner like me. I loose myself in them.

What i would like to see is a very first entry project. Not the Empty Project, that is too empty, and teaches nothing. But the simplest possible working example: load a landscape, a player, and set the camera to view the player. With comments what does what. Without any game logic, movement code or additional confusing stuff. Just loading and showing it. Just the naked skeleton of a most basic level. And without the almighty Access violation message when i try to run the level, ack.

Could somebody be so kind to create something like that?
Logged

free gamegraphics, freewaregames
http://www.reinerstileset.de
Tiles
Full Member
***
Posts: 135



View Profile WWW
« Reply #1 on: October 05, 2008, 07:05:36 AM »

Too hard, eh?   Tongue
Logged

free gamegraphics, freewaregames
http://www.reinerstileset.de
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #2 on: October 05, 2008, 08:05:26 AM »

Not hard at all but its weekend and i for example have not had the time. If we could access the old BV forum there are really good tutorials on this. I will cook something up for you. I made an old BV tutorial but it's not updated.

Stay tuned

But, it took me less than a week to understand BV by just printing out all files i could. I took templates, printed all the .gsl , .opr files and so on and just looked how they where connected. What did certain stuff in the .opr point to in the .gsl and how could it change.

I think we need to upload some older templates that are more easy to start and understand
Logged
Tiles
Full Member
***
Posts: 135



View Profile WWW
« Reply #3 on: October 05, 2008, 08:25:32 AM »

Thanks pixel_legolas. That would be much appreciated Smiley

Yeah, you learned it fast, but you had the old BV Forum in the neck. And so a ton of examples and postings. Really a shame that the old forum is closed now.

I am really lost at the moment. I always end in Access violation or Script errors. With just the try to even run a nearly blank level. Tht's why i ask for more examples. I haven't understood the basics yet. And need more stuff to have a look at.

Some guys are very fast with understanding and learning, some guys needs a bit more time and grow slow. I am the second type. It takes eons before i understand a concept, unfortunately Smiley
Logged

free gamegraphics, freewaregames
http://www.reinerstileset.de
Merrie
Full Member
***
Posts: 149



View Profile
« Reply #4 on: October 05, 2008, 04:44:02 PM »

Tiles Im working on one for you will have it up shortly. Well there appears to be a small script error, I'm checking into it then will post the example for you. However, I will get you a getting started tutorial as far as I can.

1 - Launch Gamecore > Create a new project
2 - Click on empty project > Open
3 - Name your project use one word or underscore such as Test_level1
4 - Click on the ... to select your game destination, its a good idea to make a separate file for each project.
5 - Under Items click on the Add button > Select from template > click on terrain catagory > click on editable terrain > open
6 - At the top right of the 3d window there are some grey buttons, left click on the one that looks like a magnifier glass and pull/zoom out so you can see the whole terrain.
7 - At this point you will need textures (for the ground) and a sky box. When you use textures in the engine you want them to be sized in even levels of 2= 256 x 256, 512 x 512, 1024 x 1024. You can copy the image files from the tutorial folder and paste them into your: /project/media/objects/terrain folder. It is always a good idea to move your pictures, textures into your project folder you will be working on.
8 - To place the texture on the terrain (I used a plain grass texture) make sure the terrain is selected > click on 'Edit Terrain under the Panels section > under the Terrain section switch to the layers tab > click on layer_1 > click on edit surface.
9 - Objects Surfaces panel pops up > click on the ... next to Diffuse map > find the ground texture click on it and open it will appear on your base terrain in the engine. Close the Objects Surfaces panel by clicking on cancel. Now at this point because of the error you cannot run the engine to see it, so I will update this a bit more when it gets fixed.
« Last Edit: October 05, 2008, 05:23:48 PM by Merrie » Logged

+---+---+----+----+----+----+----+----+----+----+----+----+
Vibe GameCore Training Graduate
3D Modeler - 3DS Max, AC3D, Gimp
GameCore Indie, Windows XP Media, Alienware Area 51 7500
Tiles
Full Member
***
Posts: 135



View Profile WWW
« Reply #5 on: October 06, 2008, 04:04:56 AM »

Thanks Merrie Smiley

Don't make it this complicated. I already know the told stuff. I am still after the coding bits. Like running the level to see it, hehe Smiley
« Last Edit: October 06, 2008, 04:21:00 AM by Tiles » Logged

free gamegraphics, freewaregames
http://www.reinerstileset.de
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #6 on: October 06, 2008, 07:11:15 AM »

Well running the level is not so hard. It's all in the menu file. There you will have a open world command. But, you probably want a player that moves and there is the tricky part. The template today has a soldier with some scripts, a map with scripts setting up camera and so on. And there is also a raycast that makes the player always stand up and touch the ground when spawning. All of this is just copy-paste right now. If you really like to know each line i can "almost" help you but most of the basics is pretty easy.

If you just want to run the level from a certain camera view and let it stay static...well...that's even easier
Logged
Tiles
Full Member
***
Posts: 135



View Profile WWW
« Reply #7 on: October 06, 2008, 07:58:44 AM »

No it is not. Else i wouldn't aks here. It helps me absolutely nothing when you always tell me that it is easy LOL

Biggest problem is that there are nearly no examples available. Four to be exact. Well, five when you count the Pathfinding tutorial too. Six when you count the Hello World example. The code is rarely commented and pretty complex so that it is impossible to isolate the most basic bits. And we have a incomplete new Manual plus the old partially outdated manual. Also just mainly a list of commands. We don't have the old forum anymore. We don't have its examples anymore. We don't have its scripts anymore. Nothing.

I picked up Lite C from 3D Gamestudio very quick. And made a little flight simulator in a short time. The Lite C Workshops was of a big help. And there is a ton of tutorials and examples around. And a highly active community. GameCore has nothing like that. You get mad to find a single useful bit of information here. I am even after two weeks not able to run a basic level without an Access Violation or a Script Error because i cannot find the informations i need to do it proper.

IT IS HARD now, that is it. Not easy. No tutorials, no examples, no help. That's why i ask for at least one simple example. That's why i post here. When it's so easy for you, why can't you provide an example then?

When i would wear a hat i would be ready to eat it now. Close to the point to stop this mission impossible here ...
« Last Edit: October 06, 2008, 08:32:14 AM by Tiles » Logged

free gamegraphics, freewaregames
http://www.reinerstileset.de
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #8 on: October 06, 2008, 08:48:19 AM »

I have had a busy weekend and now I am at work. This evening I will make a tutorial. Maybe even a video. At least some scripts to get you going. I understand the frustration because this is something that should already be on the site or in the game engine. Gekido said they would in some way make the old forum accesible. I hope they will fix it soon. Or at least update scripting reference more.


Here is a starting tutorial i made before. Not finished but at least some additional text to read through Smiley

Just a copy-paste from word:

Quote
CHAR.GSL ? CHARACTER MOVEMENT

Now we are going to create our script for making our character move. This is probably be the longest script we will make for this tutorial so bare with it. After this you will probably be able to create anything 

We will start really simple. First we will define different variables. I will tell you right away that this will almost become the character.gsl that you find in 3rd person sample script.

Open up notepad and save this file as char.gsl

Let?s make some definitions:

// constants
float walkSpeed = 4.5f; //This is the walking speed
float runSpeed = 9.0f; //This is the running speed
float targetOffset = 1.5f; //This will be explained later
Vector cameraOffset( 0, 2.0f, 3.0f);
//Later we are going to use something called curmatrix and this makes the camera move
//a ceratin distance from a certain object. As you know with many RPGs there is always a
//camera above the head. With this code you define how far from the head it will be in a x,y,z co-//ordination

Constants are as said before definitions that are constant, unchanging. When we say walkspeed 4.5 then it will always be 4.5. We can change this with powerups and spells and so on but now only think of it as something that does not change 

// variables
float forwardPressed = 0;
//This will later change to a 1 and will make char move forward
float backwardPressed = 0;
//This will later change to a 1 and will make char move backward
float runPressed = 0;
//This will later change to a 1 and will make char move run


Here we define variables, things that varies, they change. If you have some basic knowledge you see that I have only defined walking, running, forward and backward. We will keep it simple and then add the other movement.

I will make this entirely 3rd person but when you have finished this you can add 1st person too.

More definitions here:

Vector cameraPos; //Later
float health = 100.0f; //Let?s have HP 100 from start
float armour = 100.0f; //And 100 in armor

Matrix startingMatrix; //Later
float timeToReset = 0; //Later

Ok, here we finish definitions and start coding. I hope it will be clear to you what is happening.

Let?s start emeidatly to code:

void Initialize( Object@ object)
{
   startingMatrix = object.GetCurMatrix();
//Objects current matrix. It's like a 3d box around object

   // set the initial camera position relative to the object
   cameraPos = object.GetCurMatrix().Project( cameraOffset);
//cameraoffset is defined in beginning in X,Y,Z
}


All initializations should be done in Initialize()

As you see the camera positition takes our objects current matrix and adds the camera offset that we defined before. So it creates a ?grid? around our object and then offsets the camera.

bool CanHaveRider( Object@ object)
{
   return true;
}

If we want things to be able to attach to our player then this needs to be true

bool CanBeRider( Object@ object)
{
   return true;
}

If we want our character to be able to be attached to other things, like horse or something then this needs to be true

Next comes a long one that codes the movement

bool HandleEvent( Object@ object, const String& in event, GameEventParams@ params)
{

if (event == "Input") //All these are defined in input.cfg
   {
      if (params.stringValue == "Forward")
      {
         forwardPressed = params.floatValue;
//forwardpressed is 0, if pressed the params.floatvalue changes to 1, if released it goes //back to 0
         return true;
      }
      if (params.stringValue == "Backward")
      {
         backwardPressed = params.floatValue;
         return true;
      }
      
      
      if (params.stringValue == "Run")
      {
         runPressed = params.floatValue;
         return true;
      }
      
      return false;
   }

So, here it is. The code for making our character move. If you look at this line:

if (params.stringValue == "Forward")

The Forward comes from Input.cfg that looks like this:

KeyMapping KeyUp Forward

This means that when we press the up key on the keyboard we trigger a series of events that makes our character move forward.

The return false that you see in the end works like this:

When you press forward that line of code will turn true, but if not It will jump down to return false and nothing will happen

Now we will add something called raycast. This has be described before but here is a definition:

A raycast is when you cast a ray  You send out a ray, like a echo and it scans what is in the direction of the ray. You can think like this. You are in a pitch black room and only have a flash light. You will only see what you aim at and you can describe it. If you light on a white wall you will think ?white wall?. The same goes for a raycast. You can send it to the ground and tell the game that this is the ground and the texture is grass and so on. This can be used so that when you are on the ground and on the grass you will play the ?walking on grass? sound. Raycast is a very very important element in coding.

Here is a raycast code that I will describe after.

It is very very large again but hopefully all comments will give you a hint:

void DynamicsAdvance( Object@ object, float seconds)
{
   // we simulate character dynamics using the downcast ray method
   if (object.IsRider())
      return;

   ObjectCollide@ base = object.GetCollideObject( "Base");
//If you look at character objectview you can see a collisionbox called Base. It is also //found in the characters opr of course.
   base.SetAngularVelocity( Vector( 0, 0, 0));
//Set speed to 0 in all directions

   // re-orient the collision object so we are always upright
   Matrix mtx = base.GetMatrix();
//Set the matrix to the collision object
   mtx.YAxis.Set( 0, 1, 0);
   //Set the Y-axis in the object to upright. This makes the character to stand up 90degrees
   mtx.ZAxis = object.GetCurMatrix().ZAxis;
   mtx.Orthogonalize( 1, 2);

   bool onGround = false;
//The character should start above ground so this code places it on the ground.

   // cast a ray downward to find the ground
   float floatOffGround = 0.5f;
   float rayOffset = 0;
   float distance = floatOffGround + rayOffset;
   Vector intersect;
   Vector normal;
   object.Hide();
   Vector rayPos = mtx.T;
   rayPos.y += rayOffset;
   object.GetWorld().RayCast( rayPos, Vector( 0, -1, 0), distance, intersect, normal, false);
   distance -= rayOffset;
   if (distance < floatOffGround)
   {
      mtx.T.y += floatOffGround - distance;
      base.SetLinearVelocity( Vector( 0, 0, 0));
      onGround = true;
   }
   object.Show();
   
//I can?t explain all code here but what it does is make the object invisible and then searches for the //ground. It places our character on the ground and then shows it again
      
      
// 3rd-person camera relative movement

      object.Show();

      // determine how fast to move based on the strongest axis
      float newMoveSpeed = (backwardPressed - forwardPressed);
      if (newMoveSpeed < 0)
         newMoveSpeed = -newMoveSpeed;
      if (runPressed >= 0.5f)
         newMoveSpeed *= runSpeed;
      else
         newMoveSpeed *= walkSpeed;


//Here the new speed is calculated and called newMoveSpeed. IF for example forward is pressed //then the equation is like this:

newMoveSpeed = (backwardPressed - forwardPressed);
newMoveSpeed = (0 ? 1);
//This results in -1

//Then the code moves to

newMoveSpeed = -newMoveSpeed;

//This results in 1 and we go forward.




      if (newMoveSpeed > 0)//If more than 0 we are actually moving
      {
         // orientation of movement
         Vector camMove( 0, 0, forwardPressed - backwardPressed);
         //not in x and y. only z witch is forward or backward
         camMove.Normalize();

         // make movement camera relative
         Vector camDir = cameraPos - object.GetCurMatrix().T;
         camDir.y = 0;
         camDir.Normalize();
         Vector move( camDir.z * camMove.x + camDir.x * camMove.z, 0, camDir.z * camMove.z - camDir.x * camMove.x);

         // update the object matrix
         mtx.ZAxis = move;
         mtx.XAxis = mtx.YAxis.CrossProduct( mtx.ZAxis);
         mtx.XAxis.Normalize();
         //Change velocity of object with new move speed
         Vector vel = base.GetLinearVelocity();
         vel.x = -move.x * newMoveSpeed;
         vel.z = -move.z * newMoveSpeed;
         base.SetLinearVelocity( vel);
      }
      else //If movespeed is less than 0 it will be 0
      {
         Vector vel = base.GetLinearVelocity();
         vel.x = 0;
         vel.z = 0;
         base.SetLinearVelocity( vel);
      }

      // play the animations
      object.SetMotionVariableFloat( "Velocity", newMoveSpeed);
      object.PlayAnim( "Move");
   }

   

   base.SetMatrix( mtx);
   object.GetCurMatrix().XAxis = mtx.XAxis;
   object.GetCurMatrix().YAxis = mtx.YAxis;
   object.GetCurMatrix().ZAxis = mtx.ZAxis;

}

There you have it. A huge chunk of code for making the game do a raycast, placing the character on the ground and depending on what keyboard button we press, we move or stand still.

Let?s add the rest of the code for finalizing the char.gsl file.

void AnimAdvance( Object@ object, float seconds, float interpAmount)
{
   object.Show();
}

//This is for making animation smooth


The camera script:

void SetupCamera( Object@ object, Viewport@ viewport, ControllerCamera@ camera)
{
      // 3rd-person following camera
      // camera gets dragged along toward the player

   //   HideForm( "Racing_HUD");
   //   HideForm( "FPS_AimingCursor");
   //   ShowForm( "FPS_HUD");

      Vector focus = object.GetInterpMatrix().T;
      focus.y += targetOffset;
      //Where the camera looks

      Vector camDir = cameraPos - object.GetInterpMatrix().T;
      camDir.y = 0;
      camDir.Normalize();
      camDir *= cameraOffset.z;
      cameraPos = camDir + object.GetInterpMatrix().T;
      cameraPos.y += targetOffset;

      camera.SetPosition( cameraPos);
      camera.SetFocus( focus);
      camera.SetUp( 0, 1, 0);
      camera.SetFOV( 60);
      camera.SetTransition( 1);
      //Set camera field of view and so on
   }
So, this is the complete code for char.gsl and you will now be able to move the character that you have forward, backward and running. We can add side movement and mouse looking. That will be next chapter but we should test the code and see what happens.
Logged
Tiles
Full Member
***
Posts: 135



View Profile WWW
« Reply #9 on: October 06, 2008, 12:40:36 PM »

I am really a bit frustrated at the moment. Sorry. Didn't want to rush you. What's a bit scary is the fact that it is so quiet at this board. I would have expected more activity after the release of RC1.

Anyways, your example script here gives me hope. That's the first script with useful comments i see here. I wish the other scripts would be commented like that too Smiley

Many thanks for your patience and help Smiley
« Last Edit: October 06, 2008, 12:43:00 PM by Tiles » Logged

free gamegraphics, freewaregames
http://www.reinerstileset.de
pixel_legolas
Hero Member
*****
Posts: 786


View Profile
« Reply #10 on: October 06, 2008, 01:29:15 PM »

Well i could release the word document because i use some bold and stuff there Smiley But now im gonna eat and make a tut then Smiley
Logged
grubert
Full Member
***
Posts: 183


Everybody is very nice, but my jacket disappeared.


View Profile WWW
« Reply #11 on: October 06, 2008, 01:38:35 PM »

Tiles, if you already know some basic vector and matrix concepts, I think you should do this:

1 - Read the User Guide. Specially the topics on art pipeline, menu creation, Angelscript syntax and that one explaining the order in which GameCore loads the files and what each file types does (.gsl, .opr, .lay, .fx etc etc).
And do a fast reading of bites of the Scripting Reference and Object Properties Reference.

2 - Try to make the simplest game you can. Like a marble game. A ball, a little table, cameras and collisions working. Player movement on the ball. Some particle fx over the table also. A basic (ultra-basic) menu. Always with the User Guide opened in your browser.

After this, even if you don't manage to make some things work, you'll understand a bit more. But I'm almost sure you?ll have success in a little marble game like this (again if you have basic vector, sine/cosine and matrix math knowledge). Remember to sketch out in a paper your planning, with each element described, for the marble game, even if it's just a ball, a camera, keyboard input and collisions with table and other balls. This way you'll know much better where in the User Guide to search for things. Like: "Now let's try to make collisions". Then you go in the topics on collisions in the User Guide tutorials and Scripting Reference.
I've done that and it was a huge step for me. To be able to put it all together from scratch.

I agree with you that not being able to access the old forum examples makes things more difficult.
Other thing you could do is read the templates going to the Scripting Reference and Object Properties Reference at each new function you find which purpose you don't know. It will help you a lot.

Hope this helps. I'll pick some commented scripts I have here later. Pixel's script up here is well commented.
Logged

my portfolio and weekly posting:
http://athossampaio.blogspot.com
grubert
Full Member
***
Posts: 183


Everybody is very nice, but my jacket disappeared.


View Profile WWW
« Reply #12 on: October 06, 2008, 01:48:13 PM »

Here are some scripts of mine, some very well commented, other not that commented.
They were used with BV, so maybe there's broken a few functionality. Maybe not.

My little marble test scripts:



Logged

my portfolio and weekly posting:
http://athossampaio.blogspot.com
grubert
Full Member
***
Posts: 183


Everybody is very nice, but my jacket disappeared.


View Profile WWW
« Reply #13 on: October 06, 2008, 01:51:40 PM »

Robot in the island demo scripts:

Logged

my portfolio and weekly posting:
http://athossampaio.blogspot.com
grubert
Full Member
***
Posts: 183


Everybody is very nice, but my jacket disappeared.


View Profile WWW
« Reply #14 on: October 06, 2008, 01:53:20 PM »

Arcade flightsim demo scripts:


Logged

my portfolio and weekly posting:
http://athossampaio.blogspot.com
Pages: [1] 2 3
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!