Formula to randomly position....
Blitz3D Forums/Blitz3D Programming/Formula to randomly position....
| ||
Hi all, can someone please confirm the correct formula with the one I have if I don't want any trees anywhere NEAR my castle ANY time? I want the trees around the landscape, not in my castle AND on the landscape >< Thank you! :) |
| ||
You should not change tx and tz while doing the tests. Here is a workable method, in pseudocode. Repeat Generate random values for tx and tz on landscape If "location (tx,tz) is outside the castle" Then Exit Forever ; When we get here we have a random location on landscape but not in castle.I'm assuming the landscape is much bigger than the castle. |
| ||
What formula would this be mate? :) |
| ||
1) Make the ramdom values, STORE THEM 2) IF valx>mincastlex and Valx<MaxCastlex etc the goto 2 Also this thread http://www.blitzbasic.com/Community/posts.php?topic=95026 which is current is about "is the mouse in a box", which is the same as "It the tree in the castle" Last edited 2011 |
| ||
Whatever makes sense for your problem. I suppose the landscape is a rectangle. So you get a random point by generating two random numbers in whatever range is appropriate. Then check to see if the point is in the castle, however you do that. If it is then it is no good so try again. Keep doing this until you enough acceptable locations. Last edited 2011 |
| ||
Thanks Floyd & H&K. How can I store them, could you show me a small example? Please and thank you :) |
| ||
Rez do you really not know how to store a value? Ill give you a clue = If you are serious, then I'm afraid you should give up programming and try just Game design. |
| ||
How can I store them, could you show me a small example? Use an array, like you have done many times before. |
| ||
I thought you had to store them in a file. geez. and no. i NEVER give up |
| ||
Ok, this is what I have so far: Any help would be appreciated! :) Thank you! ^_^ |
| ||
REz can you write down in words what the above code IS doing. Then write down in words what each line is supposed to do. I Know you can fix this yourself, you just seem to have a mindset ATM of asking first. |
| ||
IF the random position of the variable, "tx#", is LESS than the variable, "tx#" PLUS the castle width, then tx# EQUALS tx# + the castle width. |
| ||
so you need two random numbers tx, and ty, so... why are you calling rnd 10 times? |
| ||
thats how tree party came. lol |
| ||
Ok, what's wrong with this formula? It's driving me @_@ LOL ![]() Last edited 2011 |
| ||
If tx# < tx# - MeshWidth(castle) ThenIn English would be If the x coord of the tree is less than the x coord of the tree minus the castle width thenWhich simpler would be If 0< -MeshWidth thenor If the meshwidth is LESS than zero then Now when is the width less than zero? 1)It never is. 2)It aways is, (cos you have used some stupid axis system If the tree isnt in the castle then accept it, else dont if the Trees x coord is Less than the the castles x coord Or the trees x coord is bigger than the castles x coord Plus the castles width Or the Trees z coord is Less than the the castles z coord Or the trees z coord is bigger than the castles z coord Plus the castles breadth Then except tree Else scrap that tree and start again Last edited 2011 |
| ||
Here's what I have, as close to what you have said as possible: |
| ||
IF tx# < MeshWidth(castle) Or tx# = MeshWidth(castle) IS the same as If tx#<= MeshWidth(Castle) I asked for if the Trees x coord is Less than the the castles x coord You done If the Trees x coord is less than the castles Width Or tx# > EntityX(castle)+MeshWidth(castle) Or tx# =EntityX(castle)+MeshWidth(castle) IS the same as Or Tx# >= EntityX(castle) +MeshWidth(Castle) Correct, The Trees X coord is Greater than the castles x coord plus Width And the same for Tz So fix the first part of both Notes The >= this is more important for excluding trees, where as we are including tree, = means exactly on the wall, so I personally would drop the =, BUT well done thinking of it This MIGHT give you a castle spaced hole, just not exactly where the castle is, because I am assuming that EntityX(Z) gives the NorthWest Point. IF entityX give the centre point, the simplest fix is If (Tx#-Meshwidth(castle)/2) > …... As you are going to use MeshWidth(castle) and EntityX(z)(castle) a lot, make three variables with their values before the loop Last edited 2011 |
| ||
This ALMOST works. It still places the trees inside the castle at times. |
| ||
If tx# < EntityX(castle) Or (tx#-MeshWidth(castle)/2) this is wrong This is not where I said put the (tx#-MeshWidth(castle)/2) Last edited 2011 |
| ||
I'm at a loss with the /2 thing |
| ||
IF entityX give the centre of the object then you DONT want to compare Tx to it. You want to compare (tx - half the width of the object) to it ie If (Tx#-Meshwidth(castle)/2) > so If tx#> ...... if entityX is the edge, If (Tx#-Meshwidth(castle)/2) >....... if entityx is the centre |
| ||
Here's what I have: |
| ||
H&K (Posted 7 hours ago) Edit #20 If tx# < EntityX(castle) Or (tx#-MeshWidth(castle)/2) this is wrong This is not where I said put the (tx#-MeshWidth(castle)/2) |
| ||
width = MeshWidth(castle) depth = MeshDepth(castle) centerx = EntityX(castle) centerz = EntityZ(castle) areax_start = centerx - (width/2) areax_end = centerx + (width/2) areaz_start = centerx - (depth/2) areaz_end = centerx + (depth/2) random# = 3700 Repeat treex = Rnd(-random, random) treez = Rnd(-random, random) inside_area_x = (treex > areax_start) And (treex < areax_end) inside_area_z = (treez > areaz_start) And (treez < areaz_end) inside_castle = inside_area_x And inside_area_z Until inside_castle = False |
| ||
I love this forum!!! |
| ||
I agree! =D Thanks, GG :p |
| ||
Repeat PositionEntity(tree,rnd(-700,700),EntityY(castleMesh),rnd(-700,700)) Until Not MeshesIntersect(castleMesh,tree) ;). A bit facetious, but it might work if the castle has a bottom plane (i.e. a stone floor). If you have a courtyard you might end up with trees in it, which might be ok. Rez, I would advise not using this "if a < b+c-c". It's very confusing. Adobt GG's method of first assigning clear and accurate variable names, then put just one on each side of the equation. Do the math just once, before the comparison. castleWestLimit= blah blah ... Repeat treeX=rnd(-700,700) treeZ=rnd(-700,700) Until (treeX < castleWestLimit) And (treeX > castleEastLimit) and (treeZ < castleSouthLimit) And (treeZ > castleNorthLimit) If it doesn't work the first time you will find it much easier to debug. Unless the problem is with Tree Party... :) |
| ||
I've been meaning to ask, whats the relevance to the posted pic? It's not showing trees in the castle and if it is, which I doubt seeing as its quite a large area with no walls to be seen and slight hills, as we can not see the castle it's just the same as posting a pic of the Mona Lisa. A screen grab of a tree growing inside a wall would be more apt as it show's problems you are having, this shows nothing of relevance. Last edited 2011 |
| ||
the problem IS from treeparty i'm afraid |
| ||
forsit est user |
| ||
Hehe |
| ||
Hmmm This whole thread makes me go @_@ If I was doing this I'd use pivots with a stored exclusion radius for each, make a new pivot for any object including castles which I didn't want trees, etc. too near - means you can easily reuse the code for anything not just castles i.e. areas of water, etc. that you don't want tree on. Or just bake a colormapped top-down view image with areas where trees could be planted and areas where they couldn't and check position against that when placing. Last edited 2011 |
| ||
here's what i have so far, but its stuck in the loop >< |
| ||
Your limit variables are only size of castle, not template for where it is Infact they are TWICE size of castle You Keep doing this until point is west of castle and east of castle and North of castle and south of castle. you have a random "next" at the end Last edited 2011 |
| ||
fixed, but its still not loading T_T |
| ||
Your limit Variables are now based only on where castle is, rather than a template of where it is. And infact are incorrectly based on this anyway. (We have already told you, "where it is +- (1/2)how big it is") You Are still doing this until point is west of castle and east of castle and North of castle and south of castle. Well done you removed the next |
| ||
dude. i never was that good at math. thanks for the compliment btw :) |
| ||
Dude... trying to take lazy shortcuts is backfiring. You have been on this for 2 weeks. The problem is you get people to write it for you, then you're on to the next thing without bothering to understand why it works. Stop writing games and start learning to program. You will make a lot faster progress, I promise you. |
| ||
Hey, I warned you once, and I'm gonna warn you ONE last time. I have a disability. If you are not going to make an effort to help, then I am going to discredit this site. YOU, John Galt, are a waste of my time. If anyone, who ISN'T John Galt wants to answer, then please do. I would APPRECIATE NOT being trampled on ESPECIALLY by you, John Galt, just because I have a disability. |
| ||
Take this as a criticism, cos it is. But please don’t take it as an attack. An amazingly similar question to yours was posted at the same time as you started this thread. That question was “How do I know if a mouse click is inside the button”. On first glance it may not seem the same as “How do I Stop my randomly placed tree from being inside the castle”, but is is exactly the same question to people who do know how to program. You have a point, and you want to know if that point falls within a boundary condition on two axis. The other poster was given an answer, that was in no way was simpler than the one you where given, and they said thanks, and went away knowing how to do it. The answer is one line (in code), and that line is in words “If the point is more to the right than the left boundary, and more to the left than the right boundary, and more to the top than the bottom boundary and more to the bottom than the top boundary, then it is in the button/castle” Or the inverse “If the point is more to the left than the left boundary, or more to the right than the right boundary, or more to the bottom than the bottom boundary or more to the top than the top boundary, then it isn't in the button/castle” Its a beginner question, but there is no shame in asking it, however once you have been given it, no further advice should be needed. You only need five (well ok 6) things, The point (x,y) The Top Boundary The Left Boundary The Bottom Boundary The Right Boundary You have been told how to get the point, and you have been told how to get all the boundaries, and in-fact where given the whole answer by GG. Yet you have still been incapable “apparently” of coding it. This can lead on to only two possible answers, either you a simply Trolling. Or you need to download/buy a book on programming preferably one with “Beginner”, “Simple”, “First steps” or “Idiots guide” in the title. [Im proud to say I own, and regularly post in the forums for First person Shooter Creator, which is a drag and drop tool, with a bit of scripting. Please rather than continuing with your project, learn to program or move to a tool like FPSC] PS. Although the list of words in the title may seem an attack, I do mean that books with those words would address the problems you are having, and in no way which to imply anything else Last edited 2011 |
| ||
FPSC is CRAP. It has so many glitches, I HAD to quit. or don't you think i would be using that? |
| ||
As an aside I just remembered - I don't think meshdepth, etc. can be relied on to give correct results - sometimes it even just returns 0 - (another reason why it would be better to use the mechanism I reccomend). |
| ||
alright, i whipped up a demo. here is what i have so far: the object of the sphere should leave the middle of the 4 boxes, and never be let in as long as the sphere is away from the 4 boxes which represent the castle. also, for some reason, its freezing >< |
| ||
PS. Although the list of words in the title may seem an attack, I do mean that books with those words would address the problems you are having, and in no way which to imply anything else. True there are many books with titles that seem derogitory in the title, but are just marketed as easier than their peers for people not from a computer science background to get at. ... for Dummies ... for idiots The beginners guide to ... if this was any other language you could read oodles of books with scores of pre writen code on a CD, sadly with blitz3D, you are severly limited and games programming for teens, is probably the entry level. The code CD is a double edged sword, it saves you typing out the begginer exercises, but if you don't pay attention, you might not notice obvious typeo's inserted by the authour in the CD version of the code when you randomly click chapter12-lesson18.c and it crashes on you, reading through the printed code and checking it against the CD allows you to look for errors, hell randomly running someone elses code without knowing what it does just opens you up to the event that they might jokingly include "delete command.com" ;if you are reading this you should know what to do. way back when, before blitz first appeared on the PC, I was re-re-re learning C and bought a few of the for dummy books, the first one I never even needed to type out and compile the code as I remembered enough to know what would happen and all was within a dos screen environment, but not typing it out, I might have auto corrected any intentional code typeo's |
| ||
How accurate do you need the tree positioning to be? If you don't mind not being able to position trees right next to the castle, this might be the easiest way to go about the problem. It's in pieces taken from examples above because I'm not going to put a lot of thought in this.Type Tree Field entity End Type For x = 0 To NumberOfTrees ;Change Number of Trees to how many trees you want t.Tree = New Tree ;Make a new tree type t\entity = LoadMesh("tree.b3d") ;Load the tree here, and call it t/entity Repeat ;Do these things... PositionEntity t\entity,rnd(-700,700),0,rnd(-700,700) ;Get New Random Position UpdateWorld ;I'm not sure if you need either of these commands. Remove if the program slows down RenderWorld ;I'm not sure if you need either of these commands. Remove if the program slows down Until EntityDistance(t\entity,castle) > 1000 ;Play around with this number until no trees are ever in the castle ;and they're still somewhat closer to it. Next Picture the above example as drawing a giant circle around the castle. The smaller the EntityDistance number, the smaller the circle, and vice-versa. Not perfect, but for what you're wanting to do, this might be the best solution. |
| ||
Also, if it's helpful, here's a screenshot just for Ginger Tea...![]() |
| ||
As long as the trees are away from the castle, and not growing in or on it, then i'm fine! :) |
| ||
Ok, I read your post, @Rob. I have tried to implement it into the tree party example. Here is what I have so far: This SHOULD have worked, but for some reason, it's still freezing. Last edited 2011 |
| ||
Your code: Until ty>water_level And EntityDistance(t\entity, castle) > 1000 Rob's code: Until EntityDistance(t\entity,castle) > 1000 ;Play around with this number until no trees are ever in the castle ;and they're still somewhat closer to it. Last edited 2011 |
| ||
yes, the trees y levels must be > than the water_level |
| ||
You should handle the problem in steps. First make sure that the trees are placed correctly (i.e. outside the castle), then add the code to make sure the trees aren't placed in the water. Don't try to do everything at the same time. |
| ||
Yeah, there's no need to confuse yourself with the AND command. Instead, if you know the height of the water, just use that in the same loop, such as:;I can't tell if you want to use types or not, but I'm going to assume you are and you've created a Tree type somewhere in here... For x = 1 To numTrees ;Change Number of Trees to how many trees you want t.Tree = New Tree ;Make a new tree type (Again, assuming you are using types) If opt=1 Then rr=Rand(1,1) ;Don't know what this is all about, but whatever you're wanting... If opt=2 Then rr=Rand(3,5) Select rr Case 1 : treename$="tree2.tp" Case 2 : treename$="tree4.tp" Case 3 : treename$="tree5.tp" Case 4 : treename$="tree8.tp" Case 5 : treename$="tree10.tp" Case 6 : treename$="tree9.tp" End Select t\entity = tpLoadtree(treename$, type_tree) ;Is there a function called "tpLoadtree"? There must be and it's not posted here... Repeat tx#=Rnd(-1700,1700) tz#=Rnd(-1700,1700) ty#=TerrainY( land,tx#,0,tz# )-2.5 ;This will help you out with water level... If ty# <= water_level ty# = water_level ;not sure what you want, this is my best guess EndIf ;If you insist on using placeholders for Positioning, then you need this line below, and it has to be in the Repeat...Until loop. PositionEntity t\entity,tx#,ty#,tz# ;And why don't you add this line, since it appears to be freezing on you If KeyDown(1) Then End ;If you hit the escape key, it will end. UpdateWorld RenderWorld ;Somebody correct me if I'm wrong, but I seem to be thinking that EntityDistance only works if RenderWorld is called... Until EntityDistance(t\entity, castle) > 1000 If t\entity <> 0 DebugLog "loaded tree "+x EndIf Next That should, in theory, make it not freeze. If it does freeze, you should now be able to hit the Escape key and the program will exit. |
| ||
Hey, I warned you once, and I'm gonna warn you ONE last time. I have a disability. If you are not going to make an effort to help, then I am going to discredit this site. You can't discredit this site. If you have a disability, fair enough. However, if you haven't made any progress in the years you have been frequenting this site, and you show no effort whatsoever to learn anything (for whatever reason, including psychological problems), it's a waste of your time using Blitz. You would make a lot more progress with a graphical system such as ClickTeam's products. That is not 'trampling on you', it's good advice.Last edited 2011 |
| ||
i love blitz, and you, nor ANYONE can't stop me. @Rob the great, thank you SO much for the help when others would not :) Here is the WORKING loop: The ONLY problem is, how do I keep trees away from other trees if they grow too close to each other? Last edited 2011 |
| ||
Edit: size problem fixed. Only problem left is in the last post. Last edited 2011 |
| ||
^ sizefix |
| ||
The ONLY problem is, how do I keep trees away from other trees if they grow too close to each other? Do exactly what you have just done for the castle and the new tree, BUT also do it for all the exiting trees and the new tree.However. You really saying that you need this line If EntityDistance(t\entity, t\entity) < 1000 |
| ||
i tried > 2 but that froze it. i need the trees distance from the trees to be greater than 2 |
| ||
please Explain this lineIf EntityDistance(t\entity, t\entity) < 1000 |
| ||
i have NO idea what i was thinking there after thinking about that line for a while. i thought that it would expand the distance between each tree only if it was less than 1000. |
| ||
See I dont think you know what that line is doing at all. Dont tell me what you thought it would do, or what is was supposed to do. Tell me WHEN it give True, and When it gives False. [I am trying to make a point here, and not just being picky] Edit: No Ill just make my point now. That line is true, when a tree is less than 1000 units away from itself, and if false when a tree is further than 1000 units away from itself. Im not going to tell you to stop prgramming. What I would suddgest, as you dont seem to want to try and learn from books, is get your entire program ATM, and go though it line by line, and write down what each line IS doing. I dont mean look at comments and say it doing what the comment says eg NOt ;This is to esc if you have a hang If KeyDown(1) Then End But rather When key 1 is held down give TRUE and then END. And you should see you are making LOADS of errors on the lines of "When the point is above the water and under the water then pass true", which is showing to everyone that you fundamentaly dont understand most of the code. For the trees question, just after you accept its a tree not in the castle, you need a For loop for all the trees in the Tree type, you then need to compare your current point with each tree in the same way as with the castle, (But as you said smaller radius) is it passes, you make that point a tree. You wont be able to do this, cos you don't know where this should go, because Ive described where it goes relative to the code you dont understand Last edited 2011 |
| ||
Think about that line of code, Rez... What if I said this to you: "Are you ever within 1000 miles of yourself...". What will the answer be to that question, 100% of the time? Is there ever going to be a moment where you are 1000 miles away from your own self? What about even 1 mile away from yourself? 1/2 a mile? This line of code is saying just that: If EntityDistance(t\entity, t\entity) < 1000 Broken into English... ;If The Distance Between Tree1 and Tree1 is Less Than 1000 Units... ;Another way of saying it could be: ;If The Distance Between Rez and Rez is Less Than 1000 Units... When you think about it that way, it doesn't make a lot of sense, does it? Like I said, is there ever going to be a moment in any reality where a single entity can be detached from it's own space it occupies? Now, think about the reverse side of the code. i tried > 2 but that froze it. i need the trees distance from the trees to be greater than 2 So, greater than....Is there ever going to be a moment where you are going to be 1000 miles away from yourself? Obviously, no. So, a more important question to ask is, when I changed that line of code to greater than 1000 units, why would Blitz freeze? I understand the direction you were headed in, but it needed a little more thought to become complete. Once you've got the trees positioned away from the castle, use a For...Next loop to check every tree against every other tree. If they're too close, either delete one of them or reposition it until they're evenly spread. Keep in mind that 1000 units is a long ways away from each other (relatively speaking, that's the same size of the radius around the castle, far too large), so you definitely want to decrease that number. To do this... For t.Tree = Each Tree ;LOOP - For Every X Tree, so to speak If KeyDown(1) Then End ;whereas you're new to programming, do this in every loop you make as a safeguard against freezing For other.Tree = Each Tree ;LOOP - For Every Y Tree, or every other tree out there If KeyDown(1) Then End ;Do this line for every loop you make... If t\entity <> other\entity ;IMPORTANT - Make sure you're not talking about the same tree If EntityDistance(t\entity,other\entity) < 100 ;If the distance between treeX and treeY is less than 100 FreeEntity t\entity ;Get rid of the tree Delete t ;Or you could reposition the tree here, whatever fits your needs EndIf EndIf Next Next If this is intimidating, check out one of my older posts to TA Games. I just ask that you don't resurrect the topic as it's getting up there in age. http://www.blitzbasic.com/Community/posts.php?topic=91477#1040827 It describes how to use Types (t.Tree stuff) in a somewhat comical, yet easy to grasp way. Now, regarding the post from John Galt, you have to understand where he's coming from. It's all too often that the forums are flooded with people who essentially want us to write their games for them. After a while, it can be exhausting to see repeated posts like this. We don't mind helping people, but we want them to learn from what we give them. When you write things such as Hey, I warned you once, and I'm gonna warn you ONE last time... it's not going to make people want to help you. He's offering some advice, not just attacking you. To be Frank, these forums are going to be a waste of your time if you're not going to learn the basics. We're not saying you can't do it, and nobody is forcing you to quit Blitz, but we are saying that as of right now, you don't have a concrete enough understanding of programming for these forums to help. H&K's exercise sounds really useful. Go through your code, line by line, and write down what's going on in pure English. No code, just good ol' human language. Nothing can help you understand the logic behind the code better than that. |
| ||
Rob! Dude! That FOR...NEXT loop right there just solved one of my oldest problems: how to compare a Type instance to all the other instances of the same Type! :D Last edited 2011 |
| ||
Does it actually work? I mean, I know I've used that same type of loop before, but I just wrote that from memory because I don't have access to my PC right now. |
| ||
it looks right, BUT I wouldnt have two loops Last edited 2011 Last edited 2011 |
| ||
ONe loop, only create tree after point passes test Last edited 2011 |
| ||
Yeah, good call. I can totally see Blitz freaking out over my system. |
| ||
ok, here's what i have so far: its not freezing. but its not positioning right either. Last edited 2011 |
| ||
Hahaha! Does a thread ever make any of you guys want to extract all your own teeth without an anaesthetic? Just me then... :) Rez you are seriously lame. All the effort Rob and H&K put in to help you, and a simple 'thanks' to acknowledge it is toooooo much effort for you to type. |
| ||
John Galt, u should talk u jerk! Now STOP hijacking my threads before I report u to the admin of this site |
| ||
I tried to be nice to EVEN u, but I can see that I can't even DO that |
| ||
Rez: For heaven's sake calm down. You have got to learn not to let people get to you so much, it's going to cause a lot of problems in your life. The internet especially is full of jerks, idiots etc; the only thing to do is ignore them, as in not responding to them at all. John: Go sit in the corner, and stop trolling Rez. Whether it's "deserved" or not, you're making the forum look bad. |
| ||
Yea, ur right adam :) thanks man :) I needed that. I already have had a bad week :( Last edited 2011 |
| ||
I think your problem, Rez, is that you value your own time EXTREMELY highly, and others' time not at all. *sits in corner* Last edited 2011 |
| ||
Adam, u better stop him before u cant stop me from messing him up! >:( |
| ||
Seriously man. Get an effin grip. Your going to "mess him up"? The internet is an easy place to throw threats about. Stick to the task at hand. I refuse to help you any more because I know you don't learn the code. It is frustrating watching other try, and I feel frustrated for you. You cut and paste code and join it together mostly. Whether that's down to a disablity or not is besides the point. You really need to do as suggested and write down what each line of code is doing. If you can't plan it in plain english, you don't have a hope of coding it. And if John is winding you up, ignore him. You don't need to respond. |
| ||
Don't try copy/pasting - this is more or less pseudocode. |
| ||
Ur right, Ross. I'm not sorry to him, but I'm sorry to u. O, and copied =D |
| ||
You need a tutor, Rez. I'm offering my services for £20/hr... seriously, I'm a good teacher and I could get you to understand this stuff in no time. You need a more intensive approach than posting back and forth on a forum. |
| ||
So what's up with the code, Rob? :) |
| ||
Well, for one this is more or less pseudo-code. And just off the top of my head, he is checking how far the middle (ie up) of the tree is from the new point. This isn't a mistake on Subirenihils part, it is in fact a more complete solution. However when you followed his advice of "Don't try copy/pasting" you should have removed it. I know you keep saying you have a disability, is it by chance one of the autism spectrum disorders, possibly Asperger's syndrome? {As a side note, to everyone else, most of us here probably would score really highly on an Asperger test} http://www.piepalace.ca/blog/asperger-test-aq-test/ Edit- lol, infact that test even has a "computer Sci" score result Last edited 2011 |
| ||
Yes, it is most definitely asperger's syndrome. I was diagnosed with A.D.D. when I was 2. It evolved into Asperger's over the years. Last edited 2011 |
| ||
Hmm....I scored a 14. That's just below the average female or male biologist. No asperger's for me. I almost wonder if that test is more aimed at how you view yourself, rather than how you appear to other people. People who see themselves as an introvert but in reality are very social people might score higher on this test than what an actual doctor's test might show. Fun, nonetheless. Regarding Rez's question... At a first glance, I can see that there's slash direction problems. Remember that "/" means divided by, while "\" represents a type field. Virtually, the only difference I noticed between your code box and Subirenihil's was the direction of slashes, but yours mixes them. Change the forward slashes "/" to back slashes "\", and it should be fine...You'll still need a way to implement it into your game, but that seems to be an issue here. Keep in mind that I'm not the author of the last example, so it's really not my place to say what's right and what's wrong with it. Are you sure this is helpful to you, Rez? With over two weeks worth of different approaches and techniques to the same problem, this has got to be confusing. Maybe you should take up John Galt's offer and look into a tutor? Having A.D.D., I'll bet nothing could be worse than reading a text book (which, by the length of my posts and the overall length of this topic, that's essentially what you're doing). Rather than reading all of this, I'll bet that some hands-on activities and exercises would be greatly beneficial to you. And, for the record, whoever says that A.D.D. prevents a person from doing the things they love just hasn't been exposed to the world enough. A.D.D. or not, I can sure see persistence on your end to do this stuff. Perhaps a nudge in the right direction will get you independent and programming in no time. |
| ||
Yes, it is very helpful. And I am thankful for all of the help. But it just won't keep trees away from other trees in the scene. Other than that, the help you all have given me is WONDERFUL, and I really appreciate it :) |
| ||
As for John Galt. He can forget it. No jerk deserves my hard earned money. |
| ||
You're hurting my feelings, Rez. Actually I'm a very good tutor. Used to tutor GCSE and A-level. There's nothing I know I can't teach. Seriously, if u can afford the fees, which are reasonable, I'll kick your ass into shape in no time. Last edited 2011 |
| ||
Alright, consider this my last post in this topic. After this, anything I offer is going to be counter-productive. I'm essentially going to take what I felt was your closest moment to having it completed, and modify it so it should (in theory, I'm not testing this at all), work. ;Be sure you have declared the Tree type up here. If you don't, this won't work. ;Below is the code if you need it. Just uncomment the three lines below. ;Type Tree ; Field entity ;End Type For x = 1 To numTrees t.Tree = New Tree If opt=1 Then rr=Rand(1,1) If opt=2 Then rr=Rand(3,5) Select rr Case 1 : treename$="tree2.tp" Case 2 : treename$="tree4.tp" Case 3 : treename$="tree5.tp" Case 4 : treename$="tree8.tp" Case 5 : treename$="tree10.tp" Case 6 : treename$="tree9.tp" End Select t\entity = tpLoadtree(treename$, type_tree) RotateEntity t\entity, Rnd(-50,50),Rnd(-180,180),Rnd(-50,50) ;fun rotations, lol. scale#=Rnd(40.8,50.0) tpScaleTree(t\entity, scale, scale, scale) cs=Rand(150,255) tptreecolor(t\entity, cs,cs,cs) Repeat If KeyDown(1) Then End tx#=Rnd(-1000,5000) tz#=Rnd(-1000,5000) ty#=TerrainY( land,tx#,0,tz# )-2.5 PositionEntity t\entity,tx#,ty#,tz# Until EntityDistance(t\entity, castle) > 1000 ;just change the number, nothing else on this line. Next ;Now that you've created the trees, we can check if they're too close to each other ;Use a separate for...next loop for this. ;As mentioned above, this isn't the best way to approach this problem. ;However, I'm drawing a blank on another way to go about this, so for now, ;I will leave it as it, but if there is a better suggestion that comes up, use ;that method as opposed to this method. For t.Tree = Each Tree If KeyDown(1) Then End For other.Tree = Each Tree If KeyDown(1) Then End If t\entity <> other\entity If EntityDistance(t\entity,other\entity) < 10 FreeEntity t\entity Delete t EndIf EndIf Next Next There you have it. If what you've provided is how you've tried to add our examples into your game, then you could quite literally copy and paste this into your game, and (again, in theory), it will do exactly what you want it to do. I'm seeing a lot of custom functions in the samples you've provided, so I'm assuming there's no problem with those. If so, well, you're going to have to start another topic for those problems. Good luck with it! |
| ||
You've hurt my feelings PLENTY of times. I am my OWN teacher. Laugh all you want, but I will be laughing all the way to the bank in no time ;) |
| ||
A screenshot of it would be nice to see how progressing you going :) |
| ||
Sure thing, Hotshot :) And Rob, testing now :) Thanks guys! :) |
| ||
Quick answer to your post at #21 /2 means divide by 2 i believe,if it has not been answered already. i.e 10/2=5 be well |
| ||
I know I said above was my last post, but this is too good to pass up. ...Laugh all you want, but I will be laughing all the way to the bank in no time ;) Oh, and by the way, I'll be taking 25% of any money you make on your game, seeing as how I've helped you with this bit of code, and I believe that H&K will get 35% (he's posted more than I have), along with a total of 30% divided among all the others on this topic who have contributed. John Galt shall receive 9% for his motivational services, and Ginger Tea will get 1% for the clever Mona Lisa comment. |
| ||
HA ha. -.- This is a FREE forum :) |
| ||
Rob you skinflint... you know I'm worth 15% and not a penny less! ;) 'Motivational services'... I like it. Last edited 2011 |
| ||
Well I already knew this topic of posting more than anyone in this forum ! 100 posts here we come! LOL :) |
| ||
HA ha. -.- This is a FREE forum :) Programming Protips, series four, episode 12: Never, ever, ever assume that anyone else's code is yours for the taking unless you've seen the licensing terms. There are no rules about this built-in to the forum, so your comment represents an attitude that is the short route to getting sued, out in the real world. Just because it would be the height of bad taste to post non-PD code on a forum doesn't mean people here can't do it; secure the permission of the author of everything you use. Always. This is the most important thing, and if you skip this step, giant scythetailed alien space bats will eat you. The entries in the code archives are public domain, and you can use them as you please without attribution (except for the really old entries from before BRL insisted everything be PD). But the forums? You should assume everything posted is property of the author until told otherwise. |
| ||
Hey, no one said you HAD to help! >:( NOW LEAVE ME ALONE! >:( |
| ||
OK !!! learn to relax and hopefully you got the code solve by now :) |
| ||
No I'm NOT going to relax! >:( You don't come on a forum and threaten someone! I KNOW MY RIGHTS! >:( |
| ||
Now LEAVE ME ALONE! >:( |
| ||
Oh good God, here we go again. |
| ||
I don't take kindly to threats |
| ||
I don't take kindly to threats Nobody's threatened you. If you're going to throw yet another tantrum over nothing, please go in the cupboard under the stairs and have it there. You know what happened last time. |
| ||
Yasha threatened me. I'm not going to have a fit. |
| ||
Yasha threatened me. I'm not going to have a fit. No he didn't. Unless you meant the bit about being eaten by a giant scythetailed alien space bat, which I have every reason to believe was probably a joke.You really need to stop getting out of your pram over silly little harmless things. For your own good. (and that's not a threat, either). |
| ||
No, I didn't. Re-read my post. In fact, if you understand my post correctly, you'll see that by the logic expressed therein, there's no way I could be threatening you. I was providing you with information that I believe is of supreme importance in the area of sharing and discussing code. Let's rephrase it, shorter: Anything not marked as free is not free. The subject is off-topic, so if you want to discuss the issue in depth a new thread would be better. I'm concerned about the general case, not specifics in this thread (I'm pretty sure Rob and the others intended their suggestions to be free for you). Last edited 2011 |
| ||
Yes, all my stuff is free, and it was a joke. And Yasha's just looking out for you. He's just saying don't assume it's free and then be sorry later. Does anyone else feel like it's time to lock this thread? It's gotten to be too off-topic. |
| ||
I apologize. I take things that sound like threats to heart. |
| ||
No I'm NOT going to relax! >:( You don't come on a forum and threaten someone! I KNOW MY RIGHTS! >:( EH? I haven't even threaten you on any shape or form or whatever as all I am saying is So unbelievable seeing over 60+ posts to solve the tree problem away from the castle as if you have said in your first post to let everyone know that your maths isn't good then there wouldnt be 60+ posts!! Everyone on the forum are trying to help you to solve your coding problem and hopefully you got the code that is working on what you want as screenshot of it would be nice to see for all people who have help you :) Nobody on this forum is Threaten you as all they want to know is Have you solve the coding problem! That is all :) P.S. It is nice of you that you have apologize and thanks for understanding :) |
| ||
Every thread is absolute gold dust where this guy's involved. Gold dust I tells ya! |
| ||
Said the heelbeely =D and your welcome, Yasha :) |
| ||
Rez... Seriously... We can actually see you like a bit of a rant, which in some respects, isnt a bad thing, but when its daft, and if it gets a bit too much, the best thing you can do is just switch your router off... Go make a coffee. I really don't know your circumstance, I don'y know your background, I'm no mind expert (I'm a builder, lol), but, when you get that people are on your back, the bigger man walks away, its a shite cliche, but, its right... Don't rise.. Walk away. @John Galt John, I suggest you back off matey... This lad has obviously a short fuse, which isnt his fault... My faults are'nt your faults and his faults are'nt mine... But we all have faults. If you think he doesnt appreciate the help, dont reply to his post, he may actually have a problem learning this stuff, that doesnt warrant a piss take does it? I think everyone should just take a step back and see whats going on here... Dabz |
| ||
Exactly my point, Dabz. I can't help that I can't easily learn this stuff. It's just who I am. :) |
| ||
I don't see where I've taken the piss out of anyone's learning ability. If anyone has an example, please quote it. I can't see a single post by Rez that indicates he's even tried to learn one single thing. Asbergers or no, there is no excuse at all for the unwarranted outburst at Yasha, or many others on here. This is not like a face to face conversation. There is time to consider your response before punching <ENTER>. Adam, u better stop him before u cant stop me from messing him up! >:( No I'm NOT going to relax! >:( You don't come on a forum and threaten someone! I KNOW MY RIGHTS! >:( |
| ||
Yet you continue to argue with me. Something you will NEVER win btw. -.- Unbelievable. -.- |
| ||
It wasn't directed at you. What's to 'win'? If you think your attitude is productive, I would take a look at the number of very helpful posters that have said they will no longer help you in this thread alone. What when you need someone to code the next problem for you? |
| ||
EDITED Last edited 2011 |
| ||
Now this thread is long over due a lock, if the problem has been solved then lets lock this and walk away. John is right in one respect, you can ignore or re read posts and carefully word your reply instead of hastily bashing out in all caps frothing at the mouth and hitting enter. You should in all honesty heed your own advice and chill for a minute, last year all JA2 had to do in some threads was just post a smilie and you exploded, some times a question is asked but it just happens to be before or after a post by John and instead of ignoring him like you say you will, you post about that leaving a valid question unanswered as you may not have seen it in your haste to post a bitch slap. An example question was what was the point of the posted pic, a trivial question mind you, but I could not see a castle to see that trees were growing too close or anything, to me that pic was as relevant to this thread as the mona lisa, a picture of a tree growing INSIDE the castle wall itself, well that is relevant. When H&K said you should write out the logic in english, this was probably the best bit of adivce in the thread, especially if it is about code you did not write, if you do this with code that looks suitable from the code archives, or someones sugested method to solve your problem, you will know how it works, not just that it does. The same advice could be taken up by others helping you, instead of posting actual blitz code an English paragraph of each function telling you what you need to do would benefit you more as you then get to know what is going on under the hood and why your attempt was flawed in the first place, eg your is this1 less than 1000 units from this1. |
| ||
Yes I agree. However, John needs to lose the lip. He's worse than me. |
| ||
write out the logic in english I want to second this, because this is very similar to how I write things myself. 1) Write in full sentences a general description of what I want a routine or program to do. 2) Break the sentences down into a pseudocode diagram (I like drawing arrows). 3) Restructure the diagram so it looks like code (add a few loops, turn "do something important" into "DoSomethingImportant()"). 4) Create stubs for the called functions that you haven't filled out yet. 5) Now you have a compilable routine, and you can fill out the functionality by repeating this for the stubs it calls! e.g. 1) "I want to put trees on the map without them overlapping other objects already in place" 2) Diagram time (Arrows and lines and boxes! Yay!) - Get a tree - Work out where the tree can go -> Generate a position -> Is it valid? Test against other objects -> Try again if the position was invalid - Put the tree on the map 3) Pseudocode time: -- My pseudocode tends to look like Python or Lisp defn PutAllTrees(map, noTrees) loop noTrees PutOneTree map defn PutOneTree(map) var obj = GetTreeEntity() Repeat var position = GenTreePosition() Until IsValid(position) PlaceTree obj, map, position 4) Stubby Blitz code time: Function PutAllTrees(map.MapType, noTrees) Local i For i = 1 to noTrees PutOneTree map Next End Function Function PutOneTree(map.MapType) Local obj = GetTreeEntity(), position.PosType Repeat position = GenTreePosition() Until IsValid(position) PlaceTree obj, map, position End Function ;Stub Function GetTreeEntity() End Function ;Stub Function GenTreePosition.PosType() End Function ;Stub Function IsValid(position.PosType) End Function ;Stub Function PlaceTree(obj, map.MapType, position.PosType) End Function Note that I've done two things here: 1) Thought about the logic of the problem without getting confused by specifics of B3D. When structuring an algorithm, all we care about is that e.g. a loop happens, not the irrelevant details of what words are used to express that. So I've clearly laid out what I want without needing to waste brainpower on formatting rules. 2) Abstracted the problem into manageable chunks. Now we know how a map is filled with trees - each tree is placed in a valid position. How do we know what a valid position is? That's a separate question and the code is now laid out in a way that means we can think about it separately, later. Incidentally, I do all but the last step with paper and pen (the Parker Jotter is my favourite). You can put your feet up, lean back on the sofa, and get programming without being tied down by that pesky computer! Programming is about logic. Actually writing it out in the programming language is an implementation detail. If you separate logical design from implementation you'll find both tasks become much easier. Last edited 2011 |
| ||
Programming is about logic. Actually writing it out in the programming language is an implementation detail. If you separate logical design from implementation you'll find both tasks become much easier. And a well written starting point can be implemented by others into their language of choice |
| ||
I was hoping someone with more clinical experience of your condition would post some advice to you, but as none has stepped forward I’m going to make one social comment and a couple of Programming comments. First the programming comments. From now on I would recommend that you post ALL code examples with line numbers, it would be better if you could keep these line number consistent across entire threads, and I would then ask for any advice to quote which line number they are referring to. You may not see the reasoning behind this right away, but hopefully you can just trust me about it. Second, just a reiteration of the earlier advice try to write down what each line you post/write is doing. And try to write this is plain but logical English. Start to use Functions more. The whole point of Functions is to compartmentalize your code and thinking Now to the social comment. I’m sure your case worker and medical adviser has told you, but your condition has probably given you a lower ability to understand jokes, or metaphors and possibly a general difficulty interacting with others. You may find that you cannot tell the difference between criticism and simple attacks, and very possibly lose your temper in long conversations that you have needed to be defensive in. You know this, and I would be very very surprised if you haven’t been told that you cannot use this as an excuse. You need to own your temper, and not let your temper own you. So I would like you to do something for me. I would like you to apologise to John. Yes I do think he is somewhat at fault. Yes I do think he has deliberately gone out of his way to rile you. However I think your responses where disproportionate and beneath you, and this in a media where you can sit back and wait before you press enter. Plus, some of Johns posts were not attacks at you, but semi apologizes. Which you where unable to recognise. [Please don’t respond with “I will never apologise etc...] {Either Apologise or don’t. No reply to this social comment is asked for nor required} |
| ||
I'm not apologizing to John until he apologizes to me for being a jerk, and treating me ON PURPOSE, like a jerk. I can't help who the hell I am. So either he apologizes to ME 1st, or there's NO deal. and NO form of reversed psychology can help him out on this one. Last edited 2011 |
| ||
For Heavean Sake....Why dont you both Just apologizing then everyone can Move on! It is time to stop being so Selfish and throwing toys out of the pram as it is time to GROW UP! End of story !! |
| ||
yeh, NO SHIT! |
| ||
nd NO form of reversed psychology can help him out on this one. I didnt use any form of reverse psychology, I told you I thought you where wrong, and that you should know that you where wrong, and asked you to apologise.Reverse psychology would have been along the lines off (Just as an example), "I dont think your man enough to apologise" Again, your diagnosis means you have the tenancy to lose your temper at people during prolonged bouts of people criticising you. This tread has been one long "youve done this wrong", so its quite understandable that your heckles whould be raised. There is no denying that John has fault here, but on a forum rather than a chat site, you have time to stop, go kick your anger pole and then come back and calmly ignore him. If we had a straw pole, Id be very surprised if more people weren't annoyed at your out bursts, that at Johns Baiting. And more importantly your rising to this baiting is meaning you are often missing valuable points made in other posts. |
| ||
i wasn't talking about you. I was talking about John |
| ||
Don't recall asking for an apology or employing reverse psychology. Please paste a quote to remind me, or are you imagining things? |
| ||
EDITED Last edited 2011 |
| ||
Rez, calm down. If you really want this thread locked, mail the moderator, or just don't response in this thread anymore. |
| ||
EDITED Last edited 2011 |
| ||
Yeah, this one's going nowhere useful, so I'll bow out. |
| ||
Rez, if my memory serves me right it was you who recently posted the following: Hi all. I've learned my lesson, on behalf of the entire forum, I'd like to say I apologize. I think this thread clearly shows you have not learned your lesson. - You still behave like an impudent child, - you still expect others to write your code for you, - you still show no gratitude for the help you are given, - you still blame others for your shortcomings, - and finally you still blame your disability for your behaviour. On the final point. I find the fact that you blame your disability extremely insulting. My brother has Aspergers syndrome and he hasn't behaved the way you do since he was about six years old (he is currently 15 years old) nor does he have difficulty learning things on his own. The reason you struggle to make progress is because you are lazy. Plain and simple. Laziness is not a disability. |
| ||
EDITED Last edited 2011 |
| ||
John galt is clearly goading. again. pack it in. rez: I've learned through experience that forum idiots are not worth getting banned for. you should edit your recent posts. |
| ||
I don't see where I've taken the piss out of anyone's learning ability. If anyone has an example, please quote it. I can't see a single post by Rez that indicates he's even tried to learn one single thing. Every thread is absolute gold dust where this guy's involved. Gold dust I tells ya! He's obviously having trouble... Thing is, I'm a dyslexic, at school half the bother I had with teachers was I couldnt express myself on paper like everyone else, thus, I had a right chew on with said teachers... I was frustrated, I knew what I wanted to write, but I couldnt... We all aren't born 100% perfect, the only way I got over it was when I went to college and they picked up on it, and then, worked with me on it, if I had something to write, they taught me how to break it down to pieces. People do have learning difficulties, and more then often if the person cannot understand it, the natural response is to vent... I've been there... Done it... Got the fridge magnet. This lad doesnt need grief IMO, he needs a combination of patience from others, as well as being taught how to respond to stuff he isnt comprehending... Granted, the latter is away from out reach, only he can fix that himself with people around him, but, online, we can surely work on the former... If not, then just ignore it... It is that easy! Dabz |
| ||
THANK you! That's all I bloody wanted was for someone to understand! |
| ||
Well, I said I would bow out, but I have to respond to Dabhand because an accusation has been made. The juxtaposition of the two quotes you made seems to imply that the one has to do with the other. Not the case. The gold dust is Rez' attitude, not his learning ability or lack thereof. No doubt he will be claiming Tourette's next. After all, there must be some reason why the forum language rules do not apply to him. |
| ||
AFAIK this is the first instance of Aspergers being meantioned, with out re reading threads from last year, the only thing meantioned was ADD, which TBH didn't sit with what I knew and the 'symptoms' displayed. Aspergers I know very little of and what I do know I read via the book "The curious incident of the dog at midnight" and the fact that Gary Numan has it after being diagnosed by his wife some time in the 90's, niether cases were shown to have bouts of, well stuff like this. But I say again, I know very little on Aspergers or any other aspects of the Autistic Spectrum. There is an old addage called "don't feed the troll's" which I and I probably speak (well type) for others, if someone posts something that could cause you to type outbursts, just don't hit post, you and others have said "just ignore any posts" and yet that has not happened. |
| ||
After all, there must be some reason why the forum language rules do not apply to him. Probably the same reason the forum personal attack rules do not apply to you.You've been on his case for months. Now, I'm not exactly a fan of Rez after all that happened before, but I don't think anybody can really blame him for blowing up at you. Maybe he is a bit slow on the uptake with Blitz, but so what? At least he's trying, and asking for help is exactly what parts of this forum exist for. There is no set quota where it becomes fair game to hurl abuse at somebody for asking a load of questions. If you can't accept that, then perhaps you should shuffle away quietly. Whatever your reasons are for picking on Rez, just give it a bloody rest. |
| ||
At least he's trying Actually, he's not. As I said, he just moans until someone writes the code. There is no set quota where it becomes fair game to hurl abuse at somebody Seems he's the one hurling abuse, and not just at me.Some of you guys are suckers for a hard luck story. It's hilarious how this guy claimed A.D.D, then as soon as H&K mentioned Asperger's, he cottoned onto that. That may give him carte blanche to be abusive to Hotshot, Yasha, Festay in your book, not mine... and before you blame it all on me for winding him up, consider the many threads where I'm not involved and he's been unpleasant. |
| ||
John Galt is the REASON I left this thread. Last edited 2011 |
| ||
There's nothing funny about the aforementioned afflictions. The joke is your changing story. |
| ||
EDITED Last edited 2011 |
| ||
EDITED Last edited 2011 |
| ||
I give up. get yourself banned again. i don't care. |
| ||
It would be very sad if you were claiming a disablity you never had, rather than just admitting you find this stuff too hard to learn (I am not saying your making it up). There's no shame in that. Regardless, you don't go about swearing at people across the forums. The knock effect of people reading these types of threads isn't great for the community or yourself. There's not much point in saying much else, as it has all been said before. It's a forum board. THINK before you post. Threatening people over the internet ain't cool... Only advise I can give, is read the advise people have given you previously, on many, many occasions. If you can't take heed of that, then your going to get nowhere. |
| ||
Ross! I HAVE a disability! FOR GOD SAKE! >:( Last edited 2011 |
| ||
Again, calm down. READ MY POST, since we're using caps. Believe it or not, most folks are trying to help you. The more this goes on, the list of people actually willing to help you is getting shorter and shorter. (I am not saying your making it up) Last edited 2011 |
| ||
Well, my score was 29 so I won't be casting any stones... Is the code working now Rez? |
| ||
Disability or not, you conduct and toilet language are not acceptable. stop using it as an excuse. you said what happened before would not happen again but it has. |
| ||
I apologize to everyone BUT John Galt, on behalf of how STUPID he is |
| ||
You still need to edit post 143 before the mods see it. apologies will eventually mean nothing if you continue doing this. john galt gets a kick out of your reaction. in future, don't react. Last edited 2011 |
| ||
john galt should be the one banned. for CONTINUING to PURPOSELY troll EVERYONE with disabilities. and i WONT stand for that! >:( |
| ||
Trolling only works if it gets responded to. |
| ||
doesn't matter. he STILL deserves to be banned. |
| ||
So, whom else has he trolled? |
| ||
No-one. |
| ||
Womens nipples taste better covered in chocolate. Sorry i no its bad taste on my part,but something has to be done to make people chill about this . :) Be Well |
| ||
Oh dear, what a sorry mess of a thread. John Gait, please refrain from posting unless you have something positive to add to a thread. Rez, please refrain from swearing. |