Questions of a beginner

Learn how to start making games.

Re: Questions of a beginner

Postby juansimat » Thu Feb 23, 2017 4:45 pm

ITomi wrote:Now I making the levels of the game. Two levels are done. But there is a little problem again: when I added the second level, the first wall-line of the first level are moved to the left with 15, and I don't know, why? Something wrong with my for statements in the Global Code "pstart"? I attached the file: it is already playable (you have to collect the dots and return to the teleport to jump to the next level), but at the first level the labirinth is holed above.


Strange behaviour. It seems that it happens only when reopening the Game Mode. The first time looks fine. It looks like the first 15 ceros of the map being ignored at char palya1[20][30] ={ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 when you made some create actor.
If i put a wall in that space, (for example {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1) you can view that it only removes the leading zeroes. Can you think what could be happening? I'm still reading the code.

BTW, when pressing down a direction key, the zozohami changes the animation when is not possible to change direction. If this is not desired, you can move ChangeAnimation inside the conditions where you change the direction. :V
̿̿¯̿̿¯̿̿'̿̿̿̿̿̿̿'̿̿'̿̿̿̿̿'̿̿̿)͇̿̿)̿̿̿̿ '̿̿̿̿̿̿\̵͇̿̿\з=(๏̯͡๏)=ε
User avatar
juansimat
 
Posts: 152
Joined: Sat Dec 19, 2009 8:23 am
Score: 27 Give a positive score

Re: Questions of a beginner

Postby ITomi » Fri Feb 24, 2017 7:55 am

Yes, it's really strange. It happened after I made the second level (palya2). And, if I insert some walls (1) instead of the leading zeroes in the first line, the line looks well.
The other thing is that I can't set varaible "pontok" ("score") to zero at the start of the levels, because it is always containes the previous value, however I would like to set it to 0. Maybe similar way containes varaible "falhelydb" ("pieces of walls") the previous values in the global code?
I thinking...
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 juansimat » Fri Feb 24, 2017 10:37 am

ITomi wrote:Yes, it's really strange. It happened after I made the second level (palya2). And, if I insert some walls (1) instead of the leading zeroes in the first line, the line looks well.
The other thing is that I can't set varaible "pontok" ("score") to zero at the start of the levels, because it is always containes the previous value, however I would like to set it to 0. Maybe similar way containes varaible "falhelydb" ("pieces of walls") the previous values in the global code?
I thinking...


Maybe is that, if you close the editor and reopen, the first time you play it don't appears shifted, can you try to add code that resets to 0 before settings the level?. If you want to reset the score to 0 on each lvl, change that variable to 0 in the script that switched to the next map.
̿̿¯̿̿¯̿̿'̿̿̿̿̿̿̿'̿̿'̿̿̿̿̿'̿̿̿)͇̿̿)̿̿̿̿ '̿̿̿̿̿̿\̵͇̿̿\з=(๏̯͡๏)=ε
User avatar
juansimat
 
Posts: 152
Joined: Sat Dec 19, 2009 8:23 am
Score: 27 Give a positive score

Re: Questions of a beginner

Postby ITomi » Fri Feb 24, 2017 1:25 pm

I think, I found the solving: just replace the line at the end of for statements with this:
Code: Select all
xhely-=faldarab.width*i;
 yhely+=faldarab.height;

instead of this old line:
Code: Select all
xhely=0;
 yhely+=faldarab.height;

But I still don't know, why is this good? Maybe the difference between screen and game coordinates?
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 juansimat » Fri Feb 24, 2017 3:49 pm

ITomi wrote:I think, I found the solving: just replace the line at the end of for statements with this:
Code: Select all
xhely-=faldarab.width*i;
 yhely+=faldarab.height;

instead of this old line:
Code: Select all
xhely=0;
 yhely+=faldarab.height;

But I still don't know, why is this good? Maybe the difference between screen and game coordinates?


Yes, you should reset the variables you are changing that way (increasing or decreasing instead of setting), when switching from levels if they were supposed to be 0 at the start. It can be an issue with memory allocation, due to only happening that bug when reloading the game, so when exporting it can never happen.
̿̿¯̿̿¯̿̿'̿̿̿̿̿̿̿'̿̿'̿̿̿̿̿'̿̿̿)͇̿̿)̿̿̿̿ '̿̿̿̿̿̿\̵͇̿̿\з=(๏̯͡๏)=ε
User avatar
juansimat
 
Posts: 152
Joined: Sat Dec 19, 2009 8:23 am
Score: 27 Give a positive score

Re: Questions of a beginner

Postby ITomi » Sat Feb 25, 2017 9:50 am

And how can I choose a random instance of an actor? I have ActorCount("ghost") and I would like choose randomly one to create an apple on its XY place.
I try this code:
Code: Select all
for (i=0;i=ActorCount("ghost");i++)
     {
         if ((round(rand(4))<2) || (i=ActorCount("ghost")))
         {
          sz=getclone(ghost.i);
          CreateActor("apple", "apple", "no parent", "no path",sz.x,sz.y,true);
         }
     }

but it is not good. What is the good code for this?
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 juansimat » Mon Feb 27, 2017 5:42 pm

ITomi wrote:And how can I choose a random instance of an actor? I have ActorCount("ghost") and I would like choose randomly one to create an apple on its XY place.
I try this code:
Code: Select all
for (i=0;i=ActorCount("ghost");i++)
     {
         if ((round(rand(4))<2) || (i=ActorCount("ghost")))
         {
          sz=getclone(ghost.i);
          CreateActor("apple", "apple", "no parent", "no path",sz.x,sz.y,true);
         }
     }

but it is not good. What is the good code for this?


The for loop consists in an initializer, an end condition, and a final expression. the "i=0" means that initializes the counter to 0 to begin with the iteration, your final expression "i++" increments the i variable, but i=ActorCount("ghost") is no condition, the condition for equality is "==" (two equals), you're only setting. But i think you better forgot to use i<ActorCount, so the loop iterates while "i" is less than the total count (remember that the indexes goes from 0 to count - 1). Also, inside the conditional "if" is the same error of equality test.

Also, the getclone don't works the way you are using: better use getclone2("ghost", i).

Furthermore, analysing what you are triying to achieve, If you want that one and only one random clone, creates an apple, you could use getclone2("ghost", rand(ActorCount("ghost")-1); instead of a loop, but if you want to make that every actor randomly creates or not, go ahead with that loop.
̿̿¯̿̿¯̿̿'̿̿̿̿̿̿̿'̿̿'̿̿̿̿̿'̿̿̿)͇̿̿)̿̿̿̿ '̿̿̿̿̿̿\̵͇̿̿\з=(๏̯͡๏)=ε
User avatar
juansimat
 
Posts: 152
Joined: Sat Dec 19, 2009 8:23 am
Score: 27 Give a positive score

Previous

Return to Getting Started

Who is online

Users browsing this forum: No registered users and 1 guest