0 Reputation

# math

Forum Home > Construct 2 General > How do I....?
 Post Reply Page  12>
 Author Message    Topic Search   Topic Options 7,492 Rep Post Options    Quote  Reply Topic: math    Posted: 14 Aug 2012 at 2:54am is there a way to learn the math on the games or these stuffs couldn't be learned??? i'm talking about math of sprites , layouts , window , ... see this example made by @kyatric Example capx in the capx you will see something like that : Sprite2.X - (Sprite2.Width/2) ?? so what does this mean? and how did you know this kind of math ? are there some common Equation like that or they are uncountable? also if it uncountable ... is there a math book that can help us on that? i know this one of the weirdest thing you ever hear but in my country they doesn't focus in shapes on math only one term of shapes on secondary school with only basics like get square meters and so on..so please help me as you can ^^thanks for reading 4,900 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 3:48am You learn by practicing, and examining examples.Sprite2.X - (Sprite2.Width/2)It means exactly what it says: The X position of the sprite, minus half of its width. It's completely logical, just think about it. 7,492 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 4:14am @Daviowareyes i know its what it what it looks like.see the example has an equation looks like this :Sprite2.X - (Sprite2.Width/2) >= Sprite.X - (Sprite.Width / 2)so the question is why he didn't use this : Sprite2.X >= Sprite.X what's the differences? also is there something that can help me in some other equations?...how can i keep exam examples if i don't know what i'm looking for? that why i'm asking if there is some common examples that i can try to check the differences. 7,061 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 4:26am The width of Sprite and Sprite2 are different, so it can't be shortened.In addition to what Davioware said it often helps to draw a diagram out to visualize. Also if you know what you are trying to calculate you can find a formula for it with google most of the time. 7,492 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 5:06am @R0J0houndok lets say i have 3 kind of enemies and i want them to with this order:-enemy1,(space = the enemy2 width),enemy2,(space = enemy3 width),enemy3-in math ways lets say enemy1.width = 20 and enemy2.width = 40 , enemy3.width = 60 so it will be like this :enemy1 then space = 40 then enemy2 then space = 60 then enemy3 so it will be a row with 3 enemies with this kind of stuffs .another example lets say i have a sprite 5x5 then i scaled to fit 1000x3000 and i want in the start of layout to have another sprite to have a position on every 50 in width so it will be a line with about 20 sprite... and so many other examples so how can i search them on google? because i never tried to search equations on google 3,002 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 6:54am I would suggest you to check Khan Academy since it has some very good video lessons on almost all math related subjects, from the very basic to more advanced ones.As of your examples, I think you need some understand of basic programming as well, maybe how a loop works. Besides that, tackle a problem one step at a time, asking yourself each basic question that will form the big answer you are looking for. If you can't find it by "googling" it, probably you are asking the wrong questions. If I understand your example right, you have 20 "cubes" that you need to be put side by side, for a start. Since you know the amount, you can just spawn the right quantity with a "repeat 20 times" loop and a "create" action. So, if you want to put a cube next to other, from the left to the right, how would you do? The first one needs to be at 0 distance from the left side, so it is right at the side. The second one needs to be at 1 times the width of one cube, so it it right next to the first. The third one at 2 times the width of one cube, so it gives space for the first two. The forth at 3 times the width... As you may have noticed there is pattern here:next X position = number of cubes * width of one cube.As an addendum, the repeat has an index, called "loopindex", that returns the number of the current repetition, starting from 0. Back to the repeat loop, you need to fill in the X of it (next X position) with that expression, so, we know now that the repeat has a loopindex that returns a number, if we are creating cubes at each repeat, that loopindex tells us the number of cubes it had created. The width of a cube is a basic expression, you can see it at the expressions help.So, into the "Create object" action, in the X position, you can translate our "equation" to:X = loopindex * cube.widthBut if you need to add a space between each one, so it it not all side by side? Well, like it is said, you need to add. So to keep the layout divided by 50, so you have 20 cubes evenly spaced, you must add 45 pixels of space to the 5 pixel cube.X = loopindex * (cube.width + 45)and that is it, if I understand you right. 20 cubes, 5 pixels wide, evenly distributed on a 1000pixels layout.The only real tricky part here is the loopindex, but it is part of the sintax of construct "language", you will need to learn it. Construct is very forgiving in that area, with not much to learn, but you will need basic programming knowledge and basic math knowledge, no way around it.Edited by dEspadas - 14 Aug 2012 at 6:59am 7,492 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 2:20pm @dEspadas thanks for your help , i have a question in khan academy what should i learn? math? or what?? also which lessons should i study that has some math on shapes and these kind of stuffs.also someone told me to learn the basics of game design is that true? or it is completely different? 3,012 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 3:45pm if your making games then you cant go wrong to read ANYTHING related to game design. Theres no reason not to read and learn from everything you can 7,492 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 3:52pm @aridale ,yes but there is alot of books of that kind of subject which one will be the most helpful for construct2 users?and should i read it all or just the part that i'm stick with it? 3,605 Rep Post Options    Quote  Reply Posted: 14 Aug 2012 at 4:23pm Wolfire made a interesting series of blogposts about the subject:http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1
 Post Reply Page  12>

 Forum Jump -- Select Forum --  Arcade  Construct 2 general  How do I....?  Your Creations  Education  Bugs   - Closed bugs  Plugins for Construct 2  Javascript SDK development  Open Topic  General game design  Tools/resources  Website issues  Help Wanted  Construct Classic Discussion   - Help & Support using Construct Classic   - Your tutorials & example files   - Your Creations   - Completed addons   - Work-in-progress addons   - Construct engineering Forum Permissions You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot delete your posts in this forumYou cannot edit your posts in this forumYou cannot create polls in this forumYou cannot vote in polls in this forum