Questions of a beginner

Learn how to start making games.

Questions of a beginner

Postby ITomi » Mon Aug 22, 2016 3:04 pm

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!
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby schnellboot » Wed Aug 24, 2016 5:02 am

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?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Questions of a beginner

Postby ITomi » Wed Aug 24, 2016 4:41 pm

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;
}
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby ITomi » Sat Aug 27, 2016 4:35 pm

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:
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby ITomi » Mon Aug 29, 2016 8:46 am

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?
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby lcl » Mon Aug 29, 2016 10:32 am

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Questions of a beginner

Postby ITomi » Mon Aug 29, 2016 1:20 pm

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. :?
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby ITomi » Sat Sep 10, 2016 4:59 pm

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.
Attachments
ukozes.zip
(1.26 KiB) Downloaded 125 times
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby schnellboot » Mon Sep 12, 2016 1:09 pm

you have to provide the data folder with the ged file
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Questions of a beginner

Postby ITomi » Sat Sep 17, 2016 7:18 am

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:
Attachments
Utkozes.zip
(427.03 KiB) Downloaded 125 times
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby ITomi » Fri Oct 28, 2016 9:46 am

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? :?:
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby lcl » Fri Oct 28, 2016 2:02 pm

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Questions of a beginner

Postby ITomi » Sat Oct 29, 2016 7:51 am

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.
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby ITomi » Sun Nov 06, 2016 5:10 pm

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". :?
User avatar
ITomi
 
Posts: 48
Joined: Sun Aug 21, 2016 1:56 pm
Location: Hungary
Score: 5 Give a positive score

Re: Questions of a beginner

Postby lcl » Wed Nov 23, 2016 10:49 am

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". :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Next

Return to Getting Started

Who is online

Users browsing this forum: No registered users and 1 guest