About symbols...

Non-platform specific questions.

About symbols...

Postby Wayra Condor » Sat Mar 08, 2008 8:42 pm

Something I don't understand is what means if on scripting I put some symbols than turns green (sometimes even text), like =, !, * and I don't know how many but... can somoene tell me whats their funcion?, because is very wreid sometimes:

Ej: If I put this: = is equal, but is I put this == is another thing!

Please someone put a tutorial of those funcions. :mrgreen:
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: About symbols...

Postby edh » Sat Mar 08, 2008 9:39 pm

Here is the meaning of some of the symbols,
= this is assignment
== this is test for equality
!= this is test for inequality
>= this is test for greater or equal
<= this is test for lesser or equal



some examples:
assignment

Code: Select all
int a;
a = 1;


equality
Code: Select all
int a;
int b;
a = 1;
b = a;

if (a == b)
{
   // they are equal!
}
else
{
   // they are not equal!
}



:!: Note: you can get a logical error by writing code like this:
Code: Select all
int a;
int b;

a = 1;
b = 2;

if (a = b)
{
  // oops, now a == b
  // a = 1 and b = 1, too
  // because we performed assignment, not test for equality
  // this is probably not what we wanted to happen
}


test for inequality
Code: Select all
int a;
int b;
a = 1;
b = 2;

if (a != b)
{
   // they are not equal!
}
else
{
   // they are equal!
}


:?: (BTW, Wayra, did you get your text effect to work?)
Last edited by edh on Sun Mar 09, 2008 12:33 am, edited 1 time in total.
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: About symbols...

Postby edh » Sun Mar 09, 2008 12:32 am

You may also want to know about these...

&& means logical "and"
|| means logical "or "

For example
Code: Select all
int a;
int b;

a = 1;
b = a;

if (a == 1 && b == 1)
{
  // then a and be are both equal to 1
}
else if (a == 1 || b == 1)
{
  // either a or b is equal to 1, not sure which one
}

User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: About symbols...

Postby Wayra Condor » Tue Mar 11, 2008 11:00 pm

Well, thanks for the explanation, but... What means "int"?
The reason I make this post is bacause I got a problem with my text, the effect is perfect, execpt in one detail, what I tried to do is that onece I press some button the second text poped up, with the same button again, appear a third text, and if it was pressed again it returned to the first text.
The effect is perfect, thanks for asking, but to make the complete effect I tried to use variables and I got screwed up with that, so what should I do?

Code: Select all
if (varaible1==1)
{ strcpy(sing1.text, "first text");//change text effect
strcpy(sing2, "first text");
variable1=2;//the variable that I try to make change in order to alternate texts
}

if (varaible1==2)
{ strcpy(sing1, "second text");
strcpy(sing2, "second text");
varaible1=1;
}

yvelocity=-10;//draw actor effect


The funny about all these is that if I change the numbers, I can make the text alternate once or twice, no more; thats why I think that the symbols are wrong.
Well, anyway thanks for help. :mrgreen:
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: About symbols...

Postby pyrometal » Wed Mar 12, 2008 1:09 am

The reason this is happening is because you are using two distinct "if" structures in your code. When your code executes, the first if is executed, but shifts the value of varaible1 to 2. Your Second piece of code can then be executed because the condition is true, so it switches your text right away to the "second text". You must use "else if" for your second block in order to avoid this problem, which will only execute if no other conditions preceding it have been fulfilled.

Code: Select all
if (varaible1==1)
{ strcpy(sing1.text, "first text");//change text effect
strcpy(sing2, "first text");
variable1=2;//the variable that I try to make change in order to alternate texts
}

else if (varaible1==2)
{ strcpy(sing1, "second text");
strcpy(sing2, "second text");
varaible1=1;
}

yvelocity=-10;//draw actor effect
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: About symbols...

Postby Bee-Ant » Wed Mar 12, 2008 7:16 am

I think this is the correct structure to change text of text actor :
Code: Select all
strcpy(MyActor.text,"your text here");
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: About symbols...

Postby Wayra Condor » Wed Mar 12, 2008 9:22 pm

And what about making a larger secuence? i tried to make a 5 secuence (again with the texts...) but the last "else if" in certain way "ate" the ones "else if" before it, maybe it could be better if someone makes a complete tutorial about function that don't apear on the function bar (those that appear in green or blue)
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: About symbols...

Postby edh » Thu Mar 13, 2008 12:15 am

I found that the Out of Vision event occurs more than once while the text actor is offscreen.

I created an out of vision flag (oov) and added a switch statement to show more than one text value.

I also use modulo (%) to make the count variables value between 0 and 5 only.

edh-changetext2.zip
multiple off screen text changes
(80.73 KiB) Downloaded 106 times
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: About symbols...

Postby Wayra Condor » Thu Mar 13, 2008 3:21 am

Yea!! it works!!!
But the bad thing is that there is a glitch... if you press the action button before the text change it disapear! (On the tutorial happens the same, why?)
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: About symbols...

Postby edh » Thu Mar 13, 2008 10:46 am

I don't know what you mean. I can't do anything to the changetext demo to make it behave the way you describe. Does the changetext demo work? It is only in your program that it is not correct?

Could you post a small example program for us to see?
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: About symbols...

Postby Wayra Condor » Thu Mar 13, 2008 10:16 pm

Well, this is your tutorial with another text that explains the glitch:
change text glitch.zip.zip
(83.29 KiB) Downloaded 99 times


What I don't understand is if there is another way for do this, with the variables I make it easly, the problem is that the limit is this:

if(variable=0)
{-code here-}

else if(variable=1)
{-another code here-}

and nothing else (I think), so if you now how to continue this, please put a list.
BTW, sorry for make so much problem with this simple thing edh :mrgreen:
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: About symbols...

Postby edh » Fri Mar 14, 2008 3:03 am

OK, I see.

What I did was create a new global integer called "canclick"

In the actor create, I initialize it to 1 (we can click the text).
In the out of vision event, I set canclick = 0 (we can not click the text).
in the draw actor, when the y position = 0, I reset canclick to 1 again (we can click the text).

Here is the working script:
edh-changetext-fixed.zip
fixed click/disappear glitch
(80.81 KiB) Downloaded 103 times


Sorry about that; I didn't notice it before.
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: About symbols...

Postby Wayra Condor » Fri Mar 14, 2008 9:11 pm

Yup, now it works propetly! but anyone knows the secuense that I listed?
if (-something-)
else if (-other thing-)
and... :?:
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Re: About symbols...

Postby edh » Sat Mar 15, 2008 9:36 am

Are you trying to do this without using events? Like in one Draw Actor script?
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: About symbols...

Postby Wayra Condor » Sat Mar 15, 2008 4:49 pm

Maybe I'll need to explain the complete proyect... I'm making a figthing game based on the mortal kombat system (with martial arts), so the text is for this, the text is only an indicator of the martial art that is being used, so it changes by pressing a key, but at the same time the text changes the character with you are playing changes its sprites an functions; if I do this with a "count" system, the character won't change, only the text, thats why I'm trying to use a global variable.
Current proyect: The King of Peru 3 (0,1%...Now reutrning form a long break!)
User avatar
Wayra Condor
 
Posts: 27
Joined: Sat Dec 08, 2007 5:05 pm
Location: Cuzco, Peru
Score: 1 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron