The Daily Click ::. Forums ::. Klik Coding Help ::. Mathematics Issue
 

Post Reply  Post Oekaki 
 

Posted By Message

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
6th July, 2009 at 13:15:13 -

I'm still having trouble with my code ..

I believe the solution is one of a mathematical nature, and to be quite honest, I'm not so good at anything more complicated than multiplication. So all you Mathematicians and Number Manipulation Wizards out there, I need you!

Lets say there's 3 rows of oranges (19 oranges total), and in the first row there are 4 oranges, in the second row there are 6 oranges, and in the third row there are 9 oranges. What is the mathematical formula which will split them in such a manner? And once that is found, how can that formula become alterable so that any amount of oranges can be put in whatever row you want without spilling the oranges from one row into another? Do you see what I'm saying?

I believe that changing the number which it is spread by (or maybe even spreading by a variable ever changeable number) could have something to do with getting it to work, but I have no clue how to get it all working mathematically, let alone implementing it into the code.

I have MSN messenger, for hotmail ... But I'm probably going to need someone who's heavily into math to help me.
Do you know much about mathematics? I vaguely remember something similar to this problem in an Algebra class when I was in school, but I don't know what the term for those kind of problems is or how they were solved.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
6th July, 2009 at 21:34:45 -

Also take a look at my other Spread Value posts, because they mostly have to do with this problem in my code.
It's a major annoyance, as building levels for a game with the 2.5d coding will take 10x as long if it can't be fixed.
It'll also be easier to messup a level and have to restart making it from scratch because of not knowing where you messed up at.

So, yea ... anyone know of a good Math problem helper site or something?
I'm gonna be googling math sites ... hopefully I can eventually find someone who can help.

GamesterXIII has been trying really hard to help me out, and I am still trying myself, but alas to no avail, as this problem seems to have a fortress of impenetrable, impervious, stone and metal built around it, being mysteriously inscrutable to all in the land, none being capable of gaining entrance to its nearly insurmountable golden bounty of usefulness hiddin within, much resembling Fort Knox and its massive treasure contained therein.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
6th July, 2009 at 21:59:22 -

I don't understand what the question is. A mathematical formula for splitting things into rows? Wha? That's not very specific.

You mean like having three rows that add up to 19? If some rows can have 0, just do:

Row 1: Random(19)
Row 2: Random(19 - Row 1)
Row 3: 19 - Row 1 - Row 2

If you can't do 0, you may have to limit it so that it's not completely random. e.g.,

Row 1: Random(8 ) + 1
Row 2: Random(8 ) + 1
Row 3: 19 - (Row 1 + Row 2)

or something similar. You'd never get anything over 8 for the first two in the last example, but there are other ways to spread it out. You could put 17 in the first one, for instance, which would mean the other two would each have at least one. It depends on whether you want a limit on how high each one can go.

Was that the question? I don't think it was.

Edited by OMC

 

  		
  		

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
6th July, 2009 at 22:08:36 -

I think you might want to re-phrase your question. Your oranges example makes absolutely no sense at all.

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
6th July, 2009 at 23:44:41 -

It can't be random OMC, just variable in the sense that if you put a stack of 1 wall over one platforms shadow to form a higher wall
or tower (if you'd rather think of it that way) until you add the green platform on top ...
Then if you put 2 walls in the next column (shadow and platform pairing), and 3 walls in the third column,
(walls being added in the frame editor, not during runtime), I need a way to make the wall instances line up in the columns no matter their number or order of placement.

Right now, the only way that the walls are not misplaced when stacking them (for the above example in this posting) is if you add a wall to the first column, add a wall to the second column, add a wall to the third column, add a wall offscreen (to keep the steady number balance), add a 2nd wall to the second column, add a 2nd wall to the third column, add another wall offscreen to keep first column numerically balanced with the other columns (3 walls 2 are offscreen), add 3rd wall to second column, and finally add the 3rd wall for the third column.

Is anyone getting this yet? ... and what I really need, is a way to set stacks (of any amount of walls) in any column, and still have everything line up correctly. By correctly I mean if I place 3 walls in the editor in the first column only, (but I have 3 columns) they should remain in the first column instead of getting moved over to the other columns, but I still need the x placement code at start of level because it is used throughout other sections of my code.

Hmm, I think I've just thought of a way without much math ... (if it works without ruining the code already in place that is)
Tell me if you think this would work: measure the x distance between wall placements and the platforms' shadow (the column), and if shadow is closer to wall, than the other shadow instances (columns) are, set wall to that closest shadow..... CRAP! THAT WON'T WORK!
That won't work cause it'll mis-interpret which shadow to pick to consider the distance between it and the wall instance!

This problem is insanity itself! What am I to do?

@OMC, YES, I need a variable limitation on each column.


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
6th July, 2009 at 23:52:39 -

I have no clue what the problem even is. o_o You pretty much fried my brain with that explanation.

 

  		
  		

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
7th July, 2009 at 00:03:39 -

Sorry ... my brain is fried too ... this is so difficult to explain!

But if I could just set position to the location of a specific instance of an object, I'd be able to avoid all this mess.
Is there some way to do that?

If there is, then that'd make life ALOT easier with all my code.
I'd be flying through it then!


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

DMT



Registered
  18/06/2009
Points
  150
7th July, 2009 at 01:50:22 -

I'm not sure, but create a hidden counter and increase it every iteration, while setting another counter to the amount of objects and then adding them? Just a thought. If you want something completely different, sorry but I can't understand your explanation...

 
I am no longer not a taco.

DMT



Registered
  18/06/2009
Points
  150
7th July, 2009 at 01:50:23 -

I'm not sure, but create a hidden counter and increase it every iteration, while setting another counter to the amount of objects and then adding them? Just a thought. If you want something completely different, sorry but I can't understand your explanation...

 
I am no longer not a taco.

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
8th July, 2009 at 09:21:03 -


Lets say there's 3 rows of oranges (19 oranges total), and in the first row there are 4 oranges, in the second row there are 6 oranges, and in the third row there are 9 oranges. What is the mathematical formula which will split them in such a manner?



Easy.
Oranges = 19
R1 = Oranges*4/19
R2 = Oranges*6/19
R3 = Oranges*9/19



Or....
Oranges = 19
R1 = 4
R2 = 6
R3 = Oranges - R2 - R1

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
9th July, 2009 at 03:51:51 -


Originally Posted by Muz

Lets say there's 3 rows of oranges (19 oranges total), and in the first row there are 4 oranges, in the second row there are 6 oranges, and in the third row there are 9 oranges. What is the mathematical formula which will split them in such a manner?



Easy.
Oranges = 19
R1 = Oranges*4/19
R2 = Oranges*6/19
R3 = Oranges*9/19



Or....
Oranges = 19
R1 = 4
R2 = 6
R3 = Oranges - R2 - R1



That's completely ridiculous and not even a formula.
This is what your post amounts to: R1 = 4, R2 = 6, R3 = 9
That's just restating the values we already know. And it's not even funny as a joke.

-.-


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
9th July, 2009 at 05:24:43 -

We're still waiting for a clear knowledge of what the question is.

 

  		
  		

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
9th July, 2009 at 07:33:13 -

What I want to know, is a formula that allows for Variation in Rows, Variation in amount within each seperate row, and Variation in the total of everything ... a balancing act. If one value changes, then they all should change.

Okay, I believe this is the formula for 3 rows: Total = 3(A+B+C) But...
... What is the formula for a variable number of Rows with a variable count of Instances within each Row?
How would I write that mathematically? Is it even possible?

See, if every Instance count within each Row were the same number, then it's easy: Total = RA
But I have no clue what to write for an ever-changing amount of another ever-changing ammount.
Total = R(AV) ??? ..

I think I know the question to ask now ... maybe ..
How can the alterable value of an instance be counted for the amount of instances with that same value?


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
9th July, 2009 at 07:56:45 -

"How can the alterable value of an instance be counted for the amount of instances with that same value?"

pick one of object
+ object value x = 1
+ Object Flag 0 is off
set Flag 0 on
add one to counter/value/whatever (which would be number of objects in that row)

If you need to place objects in rows based on their values (4 6 9) I believe you would have to code that manually.

You would need one more line for EACH row you plan to have.

Start of level Spread 1 into value x of oranges
Value X <= 4
set value X to 1
Value X >4 + Value X <=10
set Value X to 2
Value X >10 + Value X <=19
set Value X to 3

Are you planning on adding "oranges" at runtime?

How many are there going to be total?

It is still kind of vague as to what you are trying to do, so sorry if the answers I have given are inaccurate =s.







 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
9th July, 2009 at 08:18:55 -

MBK - You need to give us an example of what you are actually trying to achieve - What do you want displayed on screen? You're assuming that the answer lies with maths but there are undoubtedly multiple ways of solving the problem. There may be a much simpler way to achieve what you want, not involving any maths, but you need to tell us what it is you actually want to do.

Looking at your first example, I just whipped this up:

http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=151997

I'm pretty sure it's what you're trying to do. And you'll notice that the solution has nothing to do with mathematical formulas or setting object ids.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
9th July, 2009 at 23:42:26 -


Originally Posted by GamesterXIII

It is still kind of vague as to what you are trying to do, so sorry if the answers I have given are inaccurate =s.



GamesterXIII, I'm pretty sure that you've solved this problem with your awesome example in the post, "Spread Value Selection: how to get more control"
(I have yet to add it to my own code to make sure it works there though),
*-- BUT I'm still curious about the mathematics behind it all. --*
It seems like what you've managed to do with limited basic math and real time event code interactions is impossible to recreate in a single formula with a nearly unlimited complex mathematical stockpile of numerical persuasion.

So, there's no way to have it act variably with pure mathematics? .. and no way to write it in a formula?
Basic Math + Workaround > Advanced Math + Formula?
Strategic placement with Simple Math troops = Win the battle, while Head on attack with Advanced Math troops = Lose the Battle?
Is there no way to charge straight forward and win the war? Or is guerrilla tactics the only way to obtain victory?

Edit: @Assault Andy, Thank You Andy! ... I just looked at your example (why post on CT Forums when question was here?) .. and it seems to solve the problem as well, but how do I change the values now? Need to be able to change the numbers of oranges in each row (preferably automatically) when I place new instances so that everything will still line up. How do I change the values in the example of yours?

Nevermind, just found it. Gotta change the list values eh? ... ok, now --- How do I change the amount of rows in your example?




Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
10th July, 2009 at 00:12:02 -

K i understand now .

I believe that it might be possible to write a formula for this(?_?), but I also believe it would be way too complex to be worth it - if it were possible.

I don't think my method a workaround since you don't really have to manipulate the code because of an actual flaw in tgf/mmf etc. You just have to code one line in a specific order because of the way the code is run.

It is probably best to stick with well known formulas.

Edited by GamesterXIII

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
10th July, 2009 at 00:26:48 -


Originally Posted by GamesterXIII
K i understand now .

I don't think my method a workaround since you don't really have to manipulate the code because of an actual flaw in tgf/mmf etc. You just have to code one line in a specific order because of the way the code is run.




@GamesterXIII
Yea, you're right, it's a workaround to our flawed mathematics system though if there's no formula for it
It's very good work, whatever ya call it, no doubts about that.
I'm gonna go see if I can figure out how to place it into the 2.5d code now.


@Andy, I can't seem to find any way to change the rows in your example ...


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
10th July, 2009 at 01:34:10 -

if you have any trouble adding it just lemme know =p.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
10th July, 2009 at 03:30:17 -

MBK - I posted the example on CT forums because it's a reliable place to host files and it might help someone else in the future.

I made the example completely automatic so all you need to do is edit the list file.

If it says:
4
6
9

It will generate rows of 4, 6 and 9 oranges respectively. You simply need to change the values to change the amount of oranges in each row. To add more oranges you simply need to add more rows. EG:

4
6
9
10

will add another row of 10 oranges.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
10th July, 2009 at 05:45:05 -

<puts face to palm> ... of course! .. omg ... now I feel even more stupid .. heh ..

@AssaultAndy
Well, Thank You very much indeed Andy!
It works quite nicely and may be just what I need. So far I can't seem to get GamesterXIII's fix to work with my code. I believe it's because of all the spread values that I'm already using, it must just be too much for TGF1 to handle, or most likely I'm screwing something up. Since yours doesn't even use Alt Values or Spreads, hopefully it won't have that problem. Maybe GamesterXIII can get his version working in my code, but I currently can't.

@GamesterXIII
I've tried putting it into my code, and it ALMOST works .. but I must be doing something wrong, because it keeps creating instances and then some of the instances follow with the camera as you scroll, and it also doesn't position them close enough to the top (I've tried playing round with the values, but I'm stumped) ... so, I'm gonna have to ask if you can attempt to figure it out for me.

Guess now I'll try out Andy's method and hope like hell that it behaves with the 2.5d code, I'd be happy as long as one of them works.
Thank You for helping me so much guys. I really do appreciate it.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
10th July, 2009 at 23:25:37 -

Andy, I can't get your example to work with my code either. GamesterXIII's version is closer to what I need because the spacing between shadows can be any distance.

Sadly, I can't get either one working within my 2.5d code, so I'm either gonna have to build the levels the hard way and make a ton of extra instances to keep the balance as I go (quite a pain in the arse), or figure out a third method (a daunting task indeed).
I've been trying for the third method option by using you guy's examples for reference, but I still haven't succeeded.

Could one of you attempt to put it into the 2.5d code for me?
I know that sounds rather like a noob statement an' all, but I've been trying everything, and I still can't get it to work in my code.
Your examples work perfectly on their own, but when adding them into the 2.5d code, weird things happen (like instances following the screen).
If you guys get the time to try putting your examples into the 2.5d coding, please give it a shot.
It'd be nice to know if it's just me or if TGF doesn't like the way the codes mix together.

I'm gonna keep trying for awhile longer, but pretty soon I'm going to need to move on whether I can figure it out or not.
I'd hate to just leave it at that and move on, but I need to get back to adding slopes to the 2.5d project soon.

Btw, I recently added a landing shadow, which is quite nice, cause now you know whether you're above the platform or not, even when you can't see the ground shadow. I should probably add some sort of visual aid to help determine whether ya need to jump toward the background or toward the screen as well. Maybe I'll just add a way to look down so you can see where the ground shadow of the platform is in relation to where the ground shadow of the platform you are currently standing on is. (a type of camera movement)


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
11th July, 2009 at 19:02:25 -

post the one you have. I mailed you, but dunno if you received it =p.

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
11th July, 2009 at 20:12:56 -


Originally Posted by GamesterXIII
post the one you have. I mailed you, but dunno if you received it =p.



Did you email me? .. cause I didn't get it if so. Got a DC-mail though. I sent you an email, send me one back so I know I got it right.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?
   

Post Reply



 



Advertisement

Worth A Click