Page 1 of 3

Questions of a beginner

PostPosted: Mon Aug 22, 2016 3:04 pm
by ITomi
Hello!

I'm still new here and I have found the Game Editor a few weeks ago. I have tried it and I think, this is a great tool for create video games.
I'm a hobby game programmer with a little experience in Game Maker, FreeBasic, BlitzBasic3D, etc. and I have made a little tutorial video for other (Hungarian) beginners, which can be found on YouTube, here: https://www.youtube.com/watch?v=lOzUyNPkWFs
I would like make good games with GE, but I still have some questions, e.g. how can I place several instances of an actor in the editor screen? I tried to use left mouse click and Ctrl or Shift, but it didn't work.
My other question is that can I use the switch-case structure in the script editor? Because I got an error message after I typed it.
Thank you in advance your help; I will try return with good games by me!

Re: Questions of a beginner

PostPosted: Wed Aug 24, 2016 5:02 am
by schnellboot
1. several instances: use cloning which can be found in the upper right corner of the actor control
2. switch case: maybe your syntax is wrong, would you like to provide a snippet?

Re: Questions of a beginner

PostPosted: Wed Aug 24, 2016 4:41 pm
by ITomi
schnellboot wrote:1. several instances: use cloning which can be found in the upper right corner of the actor control


But if I use cloning, how can I reach unique and the all instances of that object? With "name." structure?

schnellboot wrote:2. switch case: maybe your syntax is wrong, would you like to provide a snippet?


I wrote it as follows:

switch (something expression)
{
case ...: ... ; break;
case ...: ... ; break;
...
default: ... ; break;
}

Re: Questions of a beginner

PostPosted: Sat Aug 27, 2016 4:35 pm
by ITomi
And how can I work with collisions in the script editor?
I would like check collisions between certain actors before I move with arrow keys. So the player presses arrow keys, he or she can move, unless collides with walls and die if collide with enemies. I tried use the collisionfree() function, but it includes all actors, and I can check the unique actors in that position. :cry:

Re: Questions of a beginner

PostPosted: Mon Aug 29, 2016 8:46 am
by ITomi
I can't stop my actor at the walls with the following code and I get the "Switch expression not integral" error message:
Code: Select all
strcpy(collobj,getactor(x,y+height+4)->name);
switch (collobj)
{
    case "wall": c_o="c_wall";
    break;
    case "ghost0": c_o="c_ghost";
    break;
    case "coin": c_o="c_coin";
    break;
    default: c_o="c_none";
    break;
};

if (c_o=="c_none")
{
 y=y+4;
 ChangeAnimation("zozohami","zozohamile",BACKWARD);
 view.y+=4;
};

Somebody can help me?

Re: Questions of a beginner

PostPosted: Mon Aug 29, 2016 10:32 am
by lcl
Your switch expression is invalid. The value inside the parenthesis after 'switch' has to be an integer value. Currently it seems that you have a string in there. Another thing you should notice is that you can't really do this:
Code: Select all
c_o = "c_wall";
That is not valid code.

The correct way to assign a string to an array of chars is to use strcpy or sprintf:
Code: Select all
strcpy(c_o, "c_wall"); //strcpy example
sprintf(c_o, "c_wall"); //sprintf example

Re: Questions of a beginner

PostPosted: Mon Aug 29, 2016 1:20 pm
by ITomi
Oh, thanks, Lcl.
But it means that "switch" can't handle string?
And what is the return value of the getactor() function? A string or an integer value or other? My code can evaluate only string, but the player always can go across the walls. :?

Re: Questions of a beginner

PostPosted: Sat Sep 10, 2016 4:59 pm
by ITomi
I tried to make a little program, in which the player can control the smiling head at right side with the arrow keys, and the other head is the obstacle at left side of the screen. But I can't move to the left, although I press the left arrow key. Somebody can help me to solve this problem? I attached the zipped program to my post.

Re: Questions of a beginner

PostPosted: Mon Sep 12, 2016 1:09 pm
by schnellboot
you have to provide the data folder with the ged file

Re: Questions of a beginner

PostPosted: Sat Sep 17, 2016 7:18 am
by ITomi
Well, I attached here the .ged file with .ged.undo file and a data folder, which contains an arial font. The .ged file contains only 3 GE heads as game sprite assets, and there is no sounds and music or others. I hope, these are the necessary things and somebody can help me... :roll:

Re: Questions of a beginner

PostPosted: Fri Oct 28, 2016 9:46 am
by ITomi
Somebody can help me to how can I appraise the "name" field of MyActor variable, that gives back the "getactor" function?
Because if I write out with StrCpy in the controller object, everything is OK, but if use an "if", the controller writes out nothing.
This is the code in the Key down event of the player object:
Code: Select all
Actor *MyActor;

MyActor=getactor(x-64,y);
//strcpy(controller.collobj,MyActor->name);
if (MyActor->name=="wall")
{
    //DestroyActor(MyActor->name);
    strcpy(controller.collobj,"It is a wall");
}
else
{
 x-=4;
};

Why not execute the "if (MyActor->name=="wall")" structure?
And:
How can I get the cloneindex from this MyActor structure? MyActor->name.cloneindex or something similar? :?:

Re: Questions of a beginner

PostPosted: Fri Oct 28, 2016 2:02 pm
by lcl
For comparing strings you have to use strcmp (=string compare). Here's an example:
Code: Select all
if (strcmp(MyActor->name, "wall") == 0)
{
    //Your code here
}

Note that when the strings are the same, the function returns 0, not 1.

And for getting the cloneindex you use:
Code: Select all
MyActor->cloneindex

And if you want the full actor name + cloneindex (for example wall.5), you use clonename:
Code: Select all
MyActor->clonename

Re: Questions of a beginner

PostPosted: Sat Oct 29, 2016 7:51 am
by ITomi
Thank you, Lcl, it works! :D
And finally, can you tell me a method in GE to solve that problem that in my pac-man game when I press two buttons simultaneously, the player can go across the walls? I would like continuous moving when the player presses the arrow buttons, but permit only one button at the same time.

Re: Questions of a beginner

PostPosted: Sun Nov 06, 2016 5:10 pm
by ITomi
And what is the problem with this code?
Code: Select all
sprintf(text,"Your lives:%d",lives);

It sometimes works perfectly (writes: "Your lives:3"), but sometimes writes out only "3". :?

Re: Questions of a beginner

PostPosted: Wed Nov 23, 2016 10:49 am
by lcl
ITomi wrote:Thank you, Lcl, it works! :D
And finally, can you tell me a method in GE to solve that problem that in my pac-man game when I press two buttons simultaneously, the player can go across the walls? I would like continuous moving when the player presses the arrow buttons, but permit only one button at the same time.

I'm not sure I understand what you mean. What kind of movement and collision are you using? Can you explain further or maybe send a demo?
ITomi wrote:And what is the problem with this code?
Code: Select all
sprintf(text,"Your lives:%d",lives);

It sometimes works perfectly (writes: "Your lives:3"), but sometimes writes out only "3". :?

Assuming that your lives variable is an integer, your code is absolutely fine. The only thing I could see messing it up like that is if you have some other code also using the same actors text variable, or maybe you have somewhere some code that is using textNumber for showing lives in that actor? That code alone can't output only "3". :)