Scrolling Game Development Kit Forum
Welcome, Guest. Please login or register.
2010-09-09, 04:48:41 PM

Login with username, password and session length
Search:     Advanced search
8920 Posts in 1007 Topics by 168 Members
Latest Member: mogzdogz
* Home Help Search Login Register
+  Scrolling Game Development Kit Forum
|-+  SGDK Version 2
| |-+  Help, Errors, FAQ
| | |-+  better way to script "react to some tiles"?
« previous next »
Pages: 1 [2] Print
Author Topic: better way to script "react to some tiles"?  (Read 2781 times)
bluemonkmn
SGDK Author
Administrator
Fanatic
*****
Posts: 2146


2678251 BlueMonkMN@gmail.com
View Profile WWW Email
« Reply #15 on: 2008-01-11, 05:01:06 PM »

when you imagine a clock, at which point lies 0°? when i use photoshop to measure the angles, 0° are at 3 o'clock. photoshop counts also counter-clockwise. +90 degrees are at 12o'clock. how sgdk does this two things? the answer would help me very much.

The code in PolarAccelerate (and elsewhere in SGDK2) will behave the same as photoshop (because this is how mathematicians view angles).  0 degrees is at 3 o'clock and it moves counter-clockwise.  The odd thing is that, in order to accomplish this, you have to you positive (+) cos and negative (-) sin.  The reason is that mathematicians use a coordinate system where the positive end of the y-axis is up, and computers use a coordinate system where the positive end of of the y-axis is down.  So reversing the sin() function makes it work just like the common understanding of angles that mathematicians use.
Logged

Tanja
Clever
Fanatic
***
Posts: 596



View Profile
« Reply #16 on: 2008-01-11, 05:34:06 PM »

thanks.
how can i provide this script for a second tile index without writing it two times?? (two tiles share one script)

if (targetSprite.TileTouchingIndex(49, false, true) >= 0)
         {
            // go left 30-
            targetSprite.AlterXVelocity(-0.34);
            // go down 30-
            targetSprite.AlterYVelocity(0.2);
         }
Logged
Tanja
Clever
Fanatic
***
Posts: 596



View Profile
« Reply #17 on: 2008-01-12, 07:10:21 AM »

for what are these comments good?

   /// <summary>
   /// Returns true when the player is pressing button 2, or false otherwise.</summary>
   /// <remarks>The term "button 2" simply refers to one of 4 customizable inputs
   /// on a sprite. There is no pre-defined meaning to the buttons.</remarks>
Logged
Jam0864
Contributor
Fanatic
**
Posts: 742


marmalade0864@hotmail.com
View Profile WWW Email
« Reply #18 on: 2008-01-12, 09:57:19 AM »

makes sense to me.
Logged
Tanja
Clever
Fanatic
***
Posts: 596



View Profile
« Reply #19 on: 2008-01-12, 10:02:55 AM »

jam: he?

i try again: for what is this good?

   /// <summary></summary>
   /// <remarks></remarks>
Logged
Jam0864
Contributor
Fanatic
**
Posts: 742


marmalade0864@hotmail.com
View Profile WWW Email
« Reply #20 on: 2008-01-12, 11:16:36 AM »

ohh I thought you meant, those comments you wrote for your script, were they understandable. lmao nevermind.  Embarrassed
Logged
durnurd
Lead Lemming
Expert
Fanatic
*****
Posts: 1155


Games completed so far: 0

durnurd@hotmail.com
View Profile WWW
« Reply #21 on: 2008-01-12, 11:33:20 AM »

Those comments are to help generate the help documentation.  Rather than updating or adding a new function then finding the file the documentation is to add or change it, you can just write the help for that function right in the code and the help compiler will automatically pick up all of those tags and make help documentation out of it.
Logged

Edward Dassmesser
Tanja
Clever
Fanatic
***
Posts: 596



View Profile
« Reply #22 on: 2008-01-12, 11:37:01 AM »

very cool, i thought so but wanted to ask.
Logged
bluemonkmn
SGDK Author
Administrator
Fanatic
*****
Posts: 2146


2678251 BlueMonkMN@gmail.com
View Profile WWW Email
« Reply #23 on: 2008-01-12, 05:03:22 PM »

thanks.
how can i provide this script for a second tile index without writing it two times?? (two tiles share one script)

if (targetSprite.TileTouchingIndex(49, false, true) >= 0)
         {
            // go left 30-
            targetSprite.AlterXVelocity(-0.34);
            // go down 30-
            targetSprite.AlterYVelocity(0.2);
         }

How about:

if ((targetSprite.TileTouchingIndex(49, false, true) >= 0) ||
    (targetSprite.TileTouchingIndex(50, false, true) >= 0))
{
      ...
}

(to check if either tile 49 or tile 50 was touched)

If you have a lot of tiles to check, maybe the original method you had was better after all (use a tile category and call TouchTiles for each category).
Logged

Tanja
Clever
Fanatic
***
Posts: 596



View Profile
« Reply #24 on: 2008-01-13, 05:13:30 AM »

oh man, what a easy one. i am so a dumbass. i thought about using "Or", but i assumed the script would not "see" the second line.
"if it is not touching tile 49, i will not look to the next line to see if it is touching tile 50"  nerd baah.......
thank you very much blue monk. will i lose my "clever" now?  laugh
Logged
durnurd
Lead Lemming
Expert
Fanatic
*****
Posts: 1155


Games completed so far: 0

durnurd@hotmail.com
View Profile WWW
« Reply #25 on: 2008-01-13, 11:41:13 AM »

The thing to remember is that the C# compiler (i.e. the SGDK2 compiler) does not see any form of whitespace except in a few important places, inside: Quotes("HelloWorld" is not the same as "Hello World", Operators (+= is not the same as + =), numbers (17 is not the same as 1 7), and identifiers such as variable and function names.  Any kind of whitespace anywhere else is just formatting for the programmer's convenience, including space, tab, and newline.  This is what allows for amusingly shaped programs (Google: IOCCC)

The other thing to point out is that boolean opperations are a little confusing.  OR runs the first check, and if true, does not run the second (because it doesn't need to).  AND runs the first check, and if false, does not run the second (because it doesn't need to).  In the reverse case, it will run the second check, even if there are four newlines and a paragraph of comments between the two conditions.
Logged

Edward Dassmesser
Tanja
Clever
Fanatic
***
Posts: 596



View Profile
« Reply #26 on: 2008-04-20, 09:57:08 AM »

some months ago i said i would write some guidance for the code object i wrote: ReactToStreams. Today i did it. Finally.
I hope you enjoy it. Please say so if you find mistakes. You can make corrections right in the doc.

http://www.burg-halle.de/~st2210/Demo_ReactToStreams.zip (369 KB)
Logged
Tanja
Clever
Fanatic
***
Posts: 596



View Profile
« Reply #27 on: 2008-04-22, 12:54:11 PM »

NOone? come on, what's up with you people?
Logged
Vincent
Clever
Fanatic
***
Posts: 343


Working on a Legacy of Kain fangame.


View Profile Email
« Reply #28 on: 2010-04-07, 02:59:49 PM »

Oh boy!  I'm so late on this topic!   Embarrassed

Anyway, if you happen to read this Tanja, I just wanted to say that your ReactToStream demo is great! Smiley  I followed the pdf and I added the ReactToStream feature in my game.  First attempt was a success! Smiley

I linked the speed of the stream with a globalcounter, so I can change it by code when I want the wind to be stronger or weaker.  I also added the ReactToStream function under a "if" condition.  So when my character transforms into a cloud of mist he is affected by the wind and when he is in normal solid form, he is not affected. It looks great! Smiley  I just have to make a couple of visual wind effects and it will be terrific!

I added you into the credits of my game under the very special thanks section.

Thanks a lot and sorry again for being so late...  Embarrassed
Logged
Pages: 1 [2] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!