Collected items question..plz.. :)

Talk about making games.

Re: Collected items question..plz.. :)

Postby lcl » Tue Jun 03, 2014 9:45 am

Zivouhr wrote:Looking at my game during gameplay and on the game editor screen, my invisible actors are seemingly completely invisible to my eyes; where they can't be collided with anymore, and I see no ghost images of them either> Possibly because I have sky actors and parallax actors behind them. I'm guessing that if nothing was behind them, then maybe they would appear as you suggest.

That problem is real, but whether it is visible for you depends on what there is behind the transparent actor, if the background is just plain one color, it's obviously easier to see the ghost picture than when the background has multiple colors and shapes on it. Also, whether or not you will see the ghost picture, depends on your screen. It might not be visible on your screen, but it may be on someone else's screen.

Mario And The Golden Key for example, used setting transparency to 1 for hiding the game over message. See what feral commented about that game:
This is a link to what feral wrote:ps. one tiny bug the 'game over' text seems to show thru the game screen on my PC..

I had that same bug with that game on my old screen. I can't see the ghost image on my new screen, but you should newer trust that everyone else has a screen as good as you may have. :)



p.s. One more thing about VisibilityState.
When you use the setting "DISABLE", the actor is both invisible, and won't receive any collision events.
When you use the setting "DONT_DRAW_ONLY", the actor is invisible, but will be able to receive collision events.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Wed Jun 04, 2014 12:44 am

Good advice. That is good to know about what is seen on other screens. Thanks.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Wed Jun 04, 2014 5:14 am

lcl wrote:
Zivouhr wrote:p.s. One more thing about VisibilityState.
When you use the setting "DISABLE", the actor is both invisible, and won't receive any collision events.
When you use the setting "DONT_DRAW_ONLY", the actor is invisible, but will be able to receive collision events.


Good tip. I'll keep it in my "how to" notes. Thanks.

One last question if you have a few minutes to spare. Saving and loading Multiple different sets of Clone groups separately in the same save event:

With the success of these codes, I want to add additional groups of clones separate from the original set to the "s" save keydown event. In other words, Treasure.0's clone set and then Bonus.0's separate set.

Here's how I thought it might work, but haven't been able to get it to approve yet as Script Error is asking me for a ) and a ; on line 3.

Player/keydown/s/script editor:

Code: Select all
int i, i2; //I'm guessing each unique set of clones needs a separate "i" integer?
char temp[256], temp2[256];  // should I create another temp for the new set of clones separate from the first clones?
for(i=0; i<500; i++), (i2=0; i2<36; i2++);   //this is probably wrong, as line 3 has a warning, expecting ; and )


Then underneath I have the sprintf details as before, only separated for each section and an error code didn't appear for that so far.

Thanks for any tips you can offer and don't worry about a fast response as I know you have other things to do as well.
I will test out some variations and see if I can figure out the set up by reading more into the C language scripting info out there on the net, too.

And finally, not to get off topic; but I have a save score system for these treasures and items, so when you gain each treasure, you get points, but the tricky part is to get those points to reward a free life, 1UP, extra life, bonus life as they call it when you hit certain point marks, like say hitting 10, 000 points, and then you gain a free life. Or even 10,001 points.
Code: Select all
score.textNumber+=100;


I have the scoring bonus arrive at high score point intervals:

Code: Select all
if (score.textNumber==1000)
{
lives.textNumber+=1;  // and it plays sound also, but I didn't code that here to keep it simple)
}
if (score.textNumber==2000)
{
lives.textNumber+=1;  // and it plays sound also, but I didn't code that here to keep it simple)
}
if (score.textNumber==5000)   //10,000, 20,000, 100,000, 1,000,000, etc...
{
lives.textNumber+=1;  // and it plays sound also, but I didn't code that here to keep it simple)
}


The tricky part is, I also tried to make it so you can hit any number at or above 1000 points for all variations of point rewards earned, but sometimes it doesn't reward a free life, when say the points are 1,001 points, since my coding doesn't give it freedom it seems.

I tried

Code: Select all
if (score.textNumber>999)
{
lives.textNumber+=1;  // and it plays sound also, but I didn't code that here to keep it simple)
}


That seemed more flexible, but then not exactly sure how to make it stop give free lives every point gained after 999 or 1000 points.

Was thinking maybe:
Code: Select all
if (score.textNumber>999<1999)   //can't quite seem to get this syntax right or the functions to use for it.
{
lives.textNumber+=1;  // and it plays sound also, but I didn't code that here to keep it simple)
}


You've done very much to help, so no worries if you don't have time to respond, as life can get very busy for all of us with other things. Thanks LCL. 8) I'm pretty positive this score question would be the last thing, along with saving different sets of different clone groups.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Collected items question..plz.. :)

Postby lcl » Wed Jun 04, 2014 1:48 pm

Hi again.

For saving additional groups of clones, you'd just have to make new arrays for those clones, add them to the same save group as the foodswitch array, and then set their variables correctly when you want to save and load them.

Because they'll have the same save group as the foodswitch array, they will be saved by the same saveVars call.
And because the variables are set to their correct values in the collision events, all you'll have to write to the key down s event is this:
Code: Select all
loadVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere"); //No need for temporary variable i, neither for the temporary string temp, nor any use of for loops, because the variables are already set to their correct values in the collision events


Only code you'll have to modify is the loading code, and here's what you'll have to do:

You don't need multiple i integers, nor do you need multiple temporary strings. That is because you can reuse the variables like this (pseudocode):
Code: Select all
int i;
char temp[256];

for (loop i from 0 to 500)
{
    sprintf(print the correct clonename to temp);
    if (foodswitch[i] is 1)
    {
        VisibilityState(temp, DISABLE);
    }
}

for (loop i from 0 to 36)
{
    sprintf(print the correct clonename to temp);
    if (someOtherSwitch[i] is 1)
    {
        VisibilityState(temp, DISABLE);
    }
}

//etc.

You can use the same integer variable for the loops as long as the loops aren't nested. Nesting loops means doing this (pseudocode):
Code: Select all
int i, j;

for (loop i from 0 to 100)
{
    for (loop j from 0 to 100) //you can't use i here because it's currently in use by the first for loop
    {
        //do something here
    }
}

//you can add a new for loop here using i or j if you want, because the variables are free for use after the for loops have finished what they're doing





Then, the score question.
There's one thing you'll have to fix right away. And that is the fact that you're trying to use textNumber as a variable holding the score. I know that the Game Editor's built-in caveman tutorial tells you to do this, but there is a reason why you should never use textNumber for anything else than showing numbers on the screen. And that is the fact that textNumber isn't reliable when you try to do coding with it. Even a simple if condition like the following one won't work:
Code: Select all
if (textNumber == 5)
{
    DestroyActor("Event Actor");
}

All you have to do to get rid of this problem is to create a global integer variable named as you want, and then use this in the draw actor event of the text actor you want to be showing the score:
Code: Select all
textNumber = myScoreVariable; //myScoreVariable is an exapmle of the score variable name

Now you can do all the conditions, additions and subtractions with the myScoreVariable and it will be 100% accurate. Only use textNumber to show the value of the variable.

Then, for getting a 1-UP every time the score reaches a multiple of 1000, just use this code:
Code: Select all
if (myScoreVariable % 1000 == 0) //Check if the remainder of myScoreVariable equals 0. If it does, that means that myScoreVariable is evenly divisible by 1000, so it must be a multiple of 1000
{
    myLivesVariable ++; //Notice that you'll want to get rid of using textNumber for storing lives, too. Oh, and "variable ++" means the same as "variable += 1"
}


That's all, hope it helps! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Thu Jun 05, 2014 2:53 am

You're awesome LCL. 8)
Thanks! I'll give these a try.

How did you learn to code so well? Did you teach yourself over the years?
I'm reading some tutorials on the C language, but have a long way to go to comprehend it all.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Collected items question..plz.. :)

Postby lcl » Thu Jun 05, 2014 6:40 am

You're welcome!

Well, what I know I have learnt by using Game Editor. I've used GE for over four and a half years, and I've learnt very much just by constantly challenging myself and trying to achieve things I haven't done before.

One thing that helped me to learn a lot was the fact that I loved coding from the beginning. I still remember that feeling of success when I, for the first time, got an actor to move on the screen when I pressed a key on the keyboard. :D

And well, until this day, I haven't ever studied programming. I've just tried things with GE and searched for solutions to my problems from this forum and also different websites telling about C coding. But I'm going to start studying programming in a university later this year, and then, after a few years of studies I hope to also be able to start contributing to the Game Editor development.

I don't know if any of this answered your question or if you were interested about my future plans coding-wise, but decided to write this information anyway :P
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Fri Jun 06, 2014 12:02 am

lcl wrote:You're welcome!

Well, what I know I have learnt by using Game Editor. I've used GE for over four and a half years, and I've learnt very much just by constantly challenging myself and trying to achieve things I haven't done before.

One thing that helped me to learn a lot was the fact that I loved coding from the beginning. I still remember that feeling of success when I, for the first time, got an actor to move on the screen when I pressed a key on the keyboard. :D

And well, until this day, I haven't ever studied programming. I've just tried things with GE and searched for solutions to my problems from this forum and also different websites telling about C coding. But I'm going to start studying programming in a university later this year, and then, after a few years of studies I hope to also be able to start contributing to the Game Editor development.

I don't know if any of this answered your question or if you were interested about my future plans coding-wise, but decided to write this information anyway :P


Sounds great LCL, and best success in your future as a programmer. You're off to a solid start I'd imagine. Thanks for that info, this way I have a better idea how you became as knowledgeable as you are in C and Game Editor.

On the topic of the saving different groups of clones, and loading too, I was just wondering about something in the code instructions:

For saving additional groups of clones, you'd just have to make new arrays for those clones, add them to the same save group as the foodswitch array, and then set their variables correctly when you want to save and load them.

Because they'll have the same save group as the foodswitch array, they will be saved by the same saveVars call.
And because the variables are set to their correct values in the collision events, all you'll have to write to the key down s event is this:

Code: Select all
loadVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere"); //No need for temporary variable i, neither for the temporary string temp, nor any use of for loops, because the variables are already set to their correct values in the collision events


In the save, can the loadVars info go anywhere above the save and it'll access the loaded info I'm guessing.
My save coding was accepted in script editor and saved during the game, but I haven't been able to test the loading yet:

Only code you'll have to modify is the loading code, and here's what you'll have to do:

You don't need multiple i integers, nor do you need multiple temporary strings. That is because you can reuse the variables like this (pseudocode):

Code: Select all
int i;
char temp[256];

for (loop i from 0 to 500)
{
sprintf(print the correct clonename to temp);
if (foodswitch[i] is 1)
{
VisibilityState(temp, DISABLE);
}
}

for (loop i from 0 to 36)
{


At first, I tried entering it as it was prior, within the load code for one variable clone group (which worked), but making the adjustment with the addition of the "if" statements as outlined above with each new variable savename clone group.

It rejected that coding though, so I am wondering:

int i;
char temp[256];

for (loop i from 0 to 500) // do I type in the quotes, "loop i from 0 to 500" ? Or is that a description of what to do?
// I had for(i from 0 to 12;) but it warns me to add a semicolon. ; I don't think I did it right.

{
sprintf(print the correct clonename to temp); // would that be sprintf(temp, "foodswitch.%i", i); //for the contents?
if (foodswitch[i] is 1) // I'm guessing "is" means equals =, since it didn't ask about that word in the warnings.
{
VisibilityState(temp, DISABLE);
}
}


Thanks for any suggestions. I'm stumped on this one last part.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Collected items question..plz.. :)

Postby lcl » Fri Jun 06, 2014 8:07 am

Zivouhr wrote:In the save, can the loadVars info go anywhere above the save and it'll access the loaded info I'm guessing.

Oh, sorry, I accidentally wrote loadVars when I should've written saveVars. So for saving the variables, all you need is one saveVars call. I'm sorry for giving you false instructions, I wasn't paying enough attention..

About the saving part.. I guess you haven't heard of pseudocode? Pseudocode means writing instructions as if like coding, but not writing it as an actual code. So when I write "loop i from 0 to 500", I mean: "i = 0; i < 500; i ++".

I'm sorry for not being clear enough about what I meant with the word pseudocode. The reason I didn't give you exact code was that I want you to code it yourself. To this point I've guided you by telling you exactly what to do, but it is better for you to start thinking the coding by yourself. This way you'll get used to the syntax and the use of different keywords.

Also, my pseudocode example was just an example of how you are able to use the same i and same temp variables for loading the states of different items. That code lacks the needed loadVars call before the first for loop.

Try implementing the code by yourself and get back to me if you face some trouble doing that.

Anyway, sorry for making that last part of instructions that difficult to understand, I wasn't probably thinking that clearly :P



And btw, one more thing about learning Game Editor and C coding. Read carefully what skydereign writes. He always provides good information about the things in GE and he's a master in coding, too. I've learnt a lot from him.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Fri Jun 06, 2014 5:55 pm

Hi LCL,

I looked up the word Pseudo after I posted earlier, and realized it meant "not real or fake", so I put two and two together and realized it was meant to be just a suggestion of about what would go there in the quotes, since writing it out with words seemed unusual for Game Editor. :D

Okay, thanks for clearing up the loadVars. I actually took that part out of the code, and noticed there were no changes so was thinking it might be a typo.

With that, I entered the coding on a smaller, more manageable test file and got a second set of clones to disappear along with the first set of clones, but the only problem now is, they are all invisible when I press the load key down "l".

I'm almost there, just need to figure out why they're all disappearing after pressing load, even though I saved it when only contacting a few of each with the player, making only a few disappear. I was going to put in a total [18], [9] of each set, after that one variable temp command up at the top of the page, but then realized each one has its own group already, so it didn't matter from what I could tell.

Will keep experimenting. And you're right, it's good to go through trial and error, as that is a great teacher.
I agree, Skydereign is very knowledgeable also. Thanks!
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Sun Jun 08, 2014 3:41 pm

lcl wrote:
Try implementing the code by yourself and get back to me if you face some trouble doing that.


Hi LCL.

I managed to get one group to save and load properly with much trial and error, but the other group just loads up completely disappeared already without ever contacting the ones that are invisible.
This is similar to the code I entered.

Under load, I have both set up about the same:
player/key down/ l (letter "L" on the keyboard): (for loading the saved items)

Code: Select all
Code: Select all
    int i;    // this automatically creates a variable after you start test the game.
    char temp[256];    // this variable, should also be above the loadVars command. Below it, and an error will pop up.
    loadVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere");
    for (i=0; i<500; i++)
    {
    sprintf(temp,"food.%i", i);
    getclone(temp)->transp=foodswitch[i];    // this is reverse order from the save order, more or less it seems.
    }

int i;
char temp[256];
loadVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere");
    for (i=0; i<500; i++)
{
   sprintf(temp,"food.%i", i);
getclone(temp)->transp=foodswitch[i];
    if (foodswitch[i] = 1)
    {
        VisibilityState(temp, DISABLE);
    }
}

    for (i=0; i<700; i++)   // added 200 onto the original 700 for example. Is this correct? foodswitch2 variable added.
{
   sprintf(temp,"food.%i", i);
getclone(temp)->transp=foodswitch2[i];
    if (foodswitch2[i] = 1)
    {
        VisibilityState(temp, DISABLE);
    }
}


-------------
player/keydown/ s / script editor //s keydown means Save when pressing "s" on the keyboard

Code: Select all
Code: Select all
    int i;    // this automatically creates a variable after you start test the game.
    char temp[256];    // this variable, should also be above the loadVars command. Below it, and an error will pop up.

    for (i=0; i<500; i++)
    {
    sprintf(temp,"food.%i", i);
    foodswitch[i]=getclone(temp)->transp;    // this is reverse order from the load order, more or less it seems.
    saveVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere");   


    for (i=0; i<700; i++)   //I'm pretty sure something goes wrong about here on my other computer, with script error.
    {
    sprintf(temp,"food.%i", i);
    foodswitch2[i]=getclone(temp)->transp;    // this is reverse order from the load order, more or less it seems.
    saveVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere");   

    //saveVars on the bottom instead of on top.    //Everything above saveVars will get saved. Beneath it, not saved.


Any advice would be greatly appreciated in my unsuccessful attempts to save multiple groups of clones. As a last resort and just in case, I could always attempt the "Case coding" set up for power ups, and just try to save all of those clones under a single clone group instead of the current multi clone group set up which is more complicated trying to save/load. 8)
I'd like to be able to save/load for both visibility state plus transparency, though not necessarily at the same time, which might explain why visibility state is missing from the save coding at the moment.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Collected items question..plz.. :)

Postby lcl » Sun Jun 08, 2014 6:11 pm

I don't have the time needed for answering right now, but I'll answer asap.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Mon Jun 09, 2014 3:35 am

No problem. Only if you get a chance. Have a good week ahead!
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Collected items question..plz.. :)

Postby foleyjo » Mon Jun 09, 2014 8:43 am

Is that code copied and pasted from GE or have you typed it out manually?

The reason I ask is because you haven't closed your for loops on the save function.
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Re: Collected items question..plz.. :)

Postby lcl » Mon Jun 09, 2014 10:32 am

Hi Zivouhr!

There seems to be a lot of things you've gotten wrong this time.

First thing being that you can't define new variables below any code. This example explains about where you can and where you can't define new variables:
Code: Select all
int myInt;

if (myInt == 5)
{
    //some code here
}

int myOtherInt; //You can't do this here!

//All variable declarations belong to the beginning of the script, or to the beginning of the current scope.
//What I mean with scope, is an area between { and }. So, you can do the following:

else if (myInt == 3)
{
    int myOtherInt; //This variable will only exist inside this else if statement

    if (myOtherInt == 2)
    {
        //some code here
    }
   
    //But you can't again define any variables here, because this is not the beginning of the scope anymore.
}


Another thing is that there shouldn't be any use of transparency in your save and load codes anymore. The system should only use VisibilityState.

An example of a working loading code:
Code: Select all
int i;
char temp[256];

loadVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere");
//Load the save group called "yoursavedgamevariablehere" from the file called "yoursavedgamehere.gdt"

for (i = 0; i < 500; i ++)
{
    sprintf(temp, "food.%i", i);
   
    if (foodswitch[i] == 1) //You need two ='s for checking IF the value is 1. Using only one = sets the value to one, causing every single food actor to disappear
    {
        VisibilityState(temp, DISABLE); //The string stored to temp is the clonename of the food clone number i.
    }
}

//Now, let's say you want to load another group of objects, and let's say there's 30 of those objects. Now you'd write:
for (i = 0; i < 30; i ++)
{
    sprintf(temp, "someOtherItem.%i", i); //someOtherItem is the name of the actor

    if (foodswitch2[i] == 1) //foodswitch2 is the array for saving the visibility of the second group of objects
    {
        VisibilityState(temp, DISABLE);
    }
}

'
What this example code needs for working is this kind of code in the player actor's collision with the food actor:
Code: Select all
foodswitch[collide.cloneindex] = 1;
VisibilityState("Collide Actor", DISABLE);

And of course same kind of codes for collisions with other collectables.

And then, for saving, simply this. Nothing else than this:
Code: Select all
saveVars("yoursavedgamehere.gdt", "yoursavedgamevariablehere");
//Save the variables of the save group "yoursavedgamevariablehere" to file "yoursavedgamehere.gdt"


So, your biggest mistakes were defining variables in wrong places, using only one = when two were needed, and mixing the use of transparency and VisibilityState. Also, when you want to make a new loop with the same variable, you don't need to think about what value the variable ended with with the old loop. That's because of the "i = 0;" part in the beginning of the loop. It resets the variable i to 0 before starting the loop.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Collected items question..plz.. :)

Postby Zivouhr » Wed Jun 11, 2014 2:20 am

foleyjo wrote:Is that code copied and pasted from GE or have you typed it out manually?

The reason I ask is because you haven't closed your for loops on the save function.


You're right; those codes were hand written as my other computer wasn't connected at the time.

LCL,

Thanks LCL for the details on defining variables. I'm a beginner so your guidance will have a larger impact once I start to understand how everything works after enough trial and error testing on my part.

Thank you very much also for the details on the coding. I was able to complete the first game's main elements, so this save code will be a welcome addition once I correctly implement it, thanks to your help. 8)

I'll post some screen shots of the game soon hopefully. I'm a much better artist than a coder, but hopefully I'll get to your level of coding skill one of these years. Thanks!
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

PreviousNext

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest