Page 1 of 2

Hello - New Member

PostPosted: Sun Jul 28, 2013 2:46 pm
by TimberDragon
Hi Guys,
I came across your editor about a week ago and have had a lot of fun making my very own first solo game. The concept was actually created along time ago and then abandoned, how ever when i seen this engine i thought it would be the perfect base for my game and so far so good!!.

My name is Tejay AKA Timberdragon and i have worked on lots of opensource games and projects for many years, the best working game is Boswars which i have created a large portion of the graphics for: http://www.BosWars.org

Some more of my art can be seen on my own site: http://www.tejaypenfold.com.au

Im posting this up now to get some feed back and maybe ask a few questions to things i have had trouble finding in the endless forums and tutorials pages :)

Look forward to getting to know those of you who are still hanging around :)
Cheers 8)

Latest Demo: Jimber2013 V0.2

ss02.jpg

Jimber2013.exe
(2.52 MiB) Downloaded 159 times

ss01.jpg

ss03.jpg

Re: Hello - New Memeber

PostPosted: Sun Jul 28, 2013 3:37 pm
by Hblade
Pretty good so far, but instead of moving the background with the penguin, you could set it up like this:
Background Object - Draw Actor - Script Editor
Code: Select all
x=view.x/2;


where 2 could be adjusted to your liking/fitting.

Re: Hello - New Memeber

PostPosted: Sun Jul 28, 2013 4:02 pm
by TimberDragon
Hi Hblade, Thanks so much for the feed back, and thanks a ton for the code. It was much smaller then mine and gives pretty good results!

Currently im using a collision to open the door at the end, but ultimately i would like to have the door open after collecting the 5 keys. i have found some explanation on how to do this, but as you can guess my stronger side is graphics and not code :? i wonder if there is a good example of item collection event code some where on the forums you could point me too?

Re: Hello - New Member

PostPosted: Sun Jul 28, 2013 6:31 pm
by Lacotemale
Awesome graphics for a first game!

So for the keys you just need to use a simple variable and if statement.

For example you could have a variable like "keys" which is an int. (declare in your variables)

For collision with a key have:

Code: Select all
keys+=1; //add +1 to the keys variable


Then put in draw actor for the door:

Code: Select all
if(keys==5)
{
//open the door code
}


Hope that helps! :)

Re: Hello - New Member

PostPosted: Mon Jul 29, 2013 12:55 am
by TimberDragon
Thanks Lacotemale, now I have to wait all day untill I finish work to try it out (frustrating) hmmm maybe im feeling sick or something ;) lol

Re: Hello - New Member

PostPosted: Mon Jul 29, 2013 6:47 am
by TimberDragon
Ok, so maybe im dumber then i thought X)

Code: Select all
if(SCORE==5)
{
 ChangeAnimation("door", "open", FORWARD); //open the door code
}


I've also used EVENT.ACTOR in place of door.

Do i need to use STATE statements with this or should this work? i get no errors, but i get no open door either

Re: Hello - New Member

PostPosted: Mon Jul 29, 2013 10:01 am
by TimberDragon
ok, ive had some progress!

Code: Select all
if(SCORE==5)

switch(doorstate)
{
   case 0:
   ChangeAnimation("Event Actor", "closed", FORWARD);
   doorstate=1;
   break;
 

  case 1:
   ChangeAnimation("Event Actor", "openwide", FORWARD);
   doorstate=3;
   break;


  case 2:
   ChangeAnimation("Event Actor", "door-01", FORWARD);
   doorstate=3;
   break;
}



Now is the tricky part, now that the door is open can i add another "if" statement? I.E. If door state is "openwide" then move player to new area?

(or on collision if door state is open then move to new area)

Also in the above code i would like to use 2 animations, "open-01" is the door opening animation while "openwide" is a single frame. I would like it to play "open-01" and then stop on "openwide" after 5 keys are collected :?

Re: Hello - New Member

PostPosted: Mon Jul 29, 2013 10:57 am
by Lacotemale
Yeah, just have an if statement like this on collision with the door actor:

Code: Select all
if(doorstate==3)
{
LoadGame("level2.ged");
}


That should probably do the trick.

Re: Hello - New Member

PostPosted: Mon Jul 29, 2013 1:33 pm
by TimberDragon
im trying to create zones maybe 4 to 5 before loading the next .ged file with a new tile set (level/location). i can use basic teleport stuff if my zones run horizontal, however i was hope to have my zones stack vertically so i can set a different back ground and things using the same tile set etc. How ever having the camera pan down to the new location is not so cool :cry:

Re: Hello - New Member

PostPosted: Mon Jul 29, 2013 4:56 pm
by skydereign
You can cause the view to jump positions, instead of panning, by setting its y variable directly. For instance if each level were only as tall as the view you could do this.
Code: Select all
view.y+= view.height;

Same goes for any consistent height. You can also do something like this.
Code: Select all
switch(cur_level)
{
    case 0:
    view.y=0;
    break;

    case 1:
    view.y=800;
    break;

    // and so on
}

Re: Hello - New Member

PostPosted: Tue Jul 30, 2013 7:50 am
by TimberDragon
Ok, I know i have doubled up with code when i should not have. One of these are causing the player to not go where its suppose too :?

I know you guys get a lot of people through here that basically want you to just write the code for them, i am not. I AM trying to figure this out before i post questions though. i try different combo's and try putting them in different places, read the tutorials on the site, read tuts on the forum, search forum for key words, then curl up in the corner and rock for a while :lol:

Anyway.. this is what i have so far:

Tux>Collision (Any Side of Door)
Code: Select all
if(doorstate==2);

MoveTo("Event Actor", -350, -1800, 15, "tux", "walls");

{
 
switch(Cur_level)
{
    case 0:
    view.y=0;
    directional_velocity=distance(x+200,y+550,tux.x,tux.y)/10; //Makes the view follow the Player.
    x=min(max(x, -550), 3000); // Limits the view at the "x" position.
    y=min(max(y, -400), -400); // Limits the view at the "y" position.
    break;
 

   case 1:
    view.y=1000;
    directional_velocity=distance(x+200,y+550,tux.x,tux.y)/10; //Makes the view follow the Player.
    x=min(max(x, -550), +3000); // Limits the view at the "x" position.
    y=min(max(y, -1500), -1500); // Limits the view at the "y" position.
    break;
 

    // and so on
}

}



Then in view i also have

View>Draw Actor
Code: Select all
if(Cur_level==0);


{
 
switch(Cur_level)
{
    case 0:
    view.y=0;
    angle=direction(x+200,y+550,tux.x,tux.y);
    directional_velocity=distance(x+200,y+550,tux.x,tux.y)/10; //Makes the view follow the Player.
    x=min(max(x, -550), 3000); // Limits the view at the "x" position.
    y=min(max(y, -400), -400); // Limits the view at the "y" position.
    break;
 

   case 1:
    view.y=1000;
    angle=direction(x+200,y+550,tux.x,tux.y);
    directional_velocity=distance(x+200,y+550,tux.x,tux.y)/10; //Makes the view follow the Player.
    x=min(max(x, -550), +3000); // Limits the view at the "x" position.
    y=min(max(y, -1500), -1500); // Limits the view at the "y" position.
    break;
 

    // and so on
}

}

Re: Hello - New Member

PostPosted: Wed Jul 31, 2013 2:43 am
by skydereign
First thing to try, your if statements end in semicolons. This negates the if statement.
Code: Select all
if(var==0);
{
    // this code always executes
}

Removing the semicolon will make that code block only trigger when the condition is met.

Re: Hello - New Member

PostPosted: Wed Jul 31, 2013 12:30 pm
by TimberDragon
Thank you for your help skydereign, i removed the semicolon but its still no behaving correctly, in fact now it didnt do anything at all :lol: So i decided to apply the K.I.S.S rule to try an eliminate any problems (K.I.S.S = Keep it simple stupid)!

So collecting 5 keys opens the door as it should using this code:

Door>Draw Actor> Script Editor:
Code: Select all
if(SCORE==5)

switch(doorstate)
{
   case 0:
   ChangeAnimation("Event Actor", "closed", FORWARD);
   doorstate=1;

  case 1:
   ChangeAnimation("Event Actor", "openwide", FORWARD);
   doorstate=2;

}


I'm thinking thats perfect... and so easy, so surely it should work just as well for the collision with door code as set out like this:

Player>Collision(Any Side of Door)
Code: Select all
if(doorstate==2)
switch(Cur_level)
{
   case 0:
   MoveTo("Event Actor", -0, -0, 15, "tux", "walls");
   Cur_level=1;

  case 1:
   MoveTo("Event Actor", -1000, -1800, 15, "tux", "walls");
   Cur_level=2;

}


But Nooooo it just does... well... nothing :evil:

Once i get him to move accurately to another Activate Region then i can start fleshing out the rest of the game. Im not really trying to make feature heavy games, just really nice looking and easy classic games. Maybe try and put a little genuine fun back into gaming :) thats my dream anyway.

Re: Hello - New Member

PostPosted: Wed Jul 31, 2013 4:51 pm
by skydereign
Okay, here's a good rule of thumb. If you have an if statement, always put the brackets. That code can easily be mistaken for something else.
Code: Select all
if(condition)
{ // <-- you should always have these, it makes the code block well defined
    // your switch
}

Now, that isn't the actual problem with your code. The problem is that your switch statement case statements don't have breaks. A break statement is used to jump out of the switch when you are done.
Code: Select all
switch(var)
{
    case 0:
    x+=5;
    // note no break statement
    // therefore if case 0 runs, it will continue running into the next case statement

    case 1:
    x+=10;
    break;
}

In recap, if var is equal to 0, the actor moves 15 pixels to the right. If it is 1, it will only move 10 pixels.

Re: Hello - New Member

PostPosted: Thu Aug 01, 2013 9:44 am
by TimberDragon
Ok, i now seem to have control over where he is landing! YAY!!

It was of course too simple...

Code: Select all
if(doorstate==2)
{
tux.y = 1000;
}


How ever im still having problems with the camera. I even know why i am also!!

I have my camera view set like this:

view>draw actor>script editor:
Code: Select all
angle=direction(x+320,y+240,tux.x,tux.y);
directional_velocity=distance(x+320,y+240,tux.x,tux.y)/10; //Makes the view follow the Player.


x=min(max(x, -550), 8000); // Limits the view at the "x" position.
y=min(max(y, -520), -520); // Limits the view at the "y" position.



So when i use this code on the collision event the view quickly flashes from the new location back to the view set in the view>draw actor code:
Code: Select all
if(doorstate==2)
{
tux.y = 1000;
view.y+= view.height;
}



How should i handle view code so i can have my specified camera view after the player has moved?