Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
I am making a Christian game, that calls for some stealth. I need some help on creating vision, and hearing for the enemy. I've seen many Blitz3d examples, but this is a 2d game in BlitzBasic. Ultimately I want a smaller pie shape thats visible for the enemy's vision, and a larger pie (full pie) thats visible for the enemy's hearing. If the Enemy hears you he will look at you, or look toward the location of the sound. I was wondering if you guys could help me. ------------------ |
||
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
Sounds like an interesting idea, except what would the pies do? Sorry, just a little confused I think you could have the guards (or whatever), respond to the sound with them "hearing" it. So like, you could code to be like "if at X amount of distance from gaurd and sound is made, make gaurd go to searching state" or something to those lines. Tell me what you think ------------------ [This message has been edited by LAVA (edited October 25, 2006).] |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
well, i know a bit of math. so, maybe this could point you in the right direction. I think you would have to check two things to find this out. first you need to use polar coordinates. Unlike cartesian coordinates (regular x and y) polar coordinates are expressed as r and theta or (length and angle) Here is a cool page I googled that shows how to do it. http://echellon.hybd.net/issues/5/articles/circle/sincos.htm Check the section called: Vectors the other way round so, once you get your angle and length between the two points, just check the distance between the two points for visibility and check if the angle falls in a specified range to simulate a 'field of view'. Its pretty easy once you are using polar coordinates. ------------------ [This message has been edited by penny (edited October 25, 2006).] |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Lava: I think Penny knows what I'm talking about. A Simulation of a field of vision, and hearing. The pies are for the visuals of the player. It answers the questions of where the enemy is looking, how far he can look, and if I move into a certain space will he see. Penny: WHOA! :Confused: Ok, so you know more math than I do, would you mind rephrasing that? (Give me a break I'm only in 6th grade.) What do you program in? I know you are mostly story writer. Basicly to summarize it, I want to create a colored visible circle, or pie to simulate my enemies vision. The hearing would be able to be a full circle, and its range would be hindered by objects, but not stopped. The reaction to you being in his hearing range would cause him to rotate his sight toward you, and move toward the sound. The vision would cause him to move toward you. ------------------ |
||
Ereon Member Posts: 1018 From: Ohio, United States Registered: 04-12-2005 |
If it were me, for the sake of simplicity, I would use a sprite in the shape I wanted and set it up with pixel perfect collision (if BB has that, which I'm pretty sure they do). That way all you make is a large, invisible or transparent sprite, and use that as your line of sight or line of vision, while having it rotate with the sprite that is using it to look or hear. ------------------ Portia The Merchant of Venice |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
Mene, I'm thirty-three. Its been a long while since I was in sixth grade. For a 6th grader, this problem has a lot of math. Do you know yet about algebraic functions and variables? You might since you have been programming. If not, you might just want to read up on it, or try something with less math. Here is a little more info, to get you started. Feel free to ask more questions. To locate a specific point on a plane (or screen in your case), you need a coordinate system, an origin and a set of coordinates. There are several different types of coordinate systems. The two I am talking about are Cartesian and polar coordinate systems. If you have positioned sprites on the screen, then you most likely have used a vertically mirrored first quadrant Cartesian coordinate system. Don't get freaked out by the terminology. This is simply the regular rectangular grid coordinates, with an origin(a starting point) in the top, left corner. Fortunately, since all computers screens use the Cartesian system, you don't need any math to plot a point. I just looked up the command for Blitz to put a dot on the screen: WritePixel x,y,argb. See the 'x' and 'y', these are the standard coordinates of the 2D Cartesian system (FYI, 3D adds 'z'). Now its important to remember that there is an origin! When you type 'WritePixel 60,80,color' and run the program. The computer starts at the top left of the screen(the origin) and moves 60 units(pixels) horizontally(to the right), and 80 units vertical(towards the bottom) and then puts a dot there. Just keep that in mind. To find a location, you need a coordinate set for the destination point (x,y) and an *origin* (a starting point, which for computers is the top left of screen by default) Ok, Now there is another way to find a position on the screen, but since its not the standard way of doing it, it requires some math; in fact trigonometry. But, don't let that freak you out either. I had basic trig figured out by eighth great. The other system is called polar coordinates. With polar coordinates, you still have an origin(starting point) and destination point, but the coordinates to get there are different. Instead of using x and y and traveling across and down, you use r and theta(see below). 'r' is the distance to the destination point from origin, and 'theta' is the angle to travel at to get there from the origin. Blitz uses degrees for angles. There are 360 degrees in a full circle(in case you didn't know), anything less than 360 is a pie. Also, since we are calculating the coordinates we can set the origin to any spot on the screen. See the page I linked to in my other post for info on how to convert a polar coordinate to Cartesian. ** In polar coordinates, 'r' is actually short for 'radius', as in the distance from the middle of a circle to the edge. And theta is used because in geometry, angles are always represented with greek characters. ** Other programming languages use radians for angles instead of degrees. See here about converting between the two ------------------ |
||
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
quote: Yes, it does ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Ereon: The problem with that is alignment. If my vision turns, and I want to look elsewhere, it will turn on the center axis, and will collide with the enemies own circle. I could create frames for each degree, but 360 frames doesn't sound appitizing. Penny: I'm not sure what "Algebraic functions" are, but I do understand variables, due to programming. (I've noticed it would be hard to get around without knowing variables.) I certainly don't understand Cosine, and Sine. I understand using x, y, and z (I've played around with 3d some), and have written a few games, but have never had to understand Cartesian, or Sine, or Cosine yet. I being the youngest in my family have heard alot of Math conversations above my head, and am picking up on polar coordinates. I've heard radius, and circumfrance before, but never understood how to apply radius. Sorry if I'm being troublesome, but I still need some help on how to apply this. ------------------ |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
Well, I can't give you code as I'm not much of a programmer. I just know math. Maybe someone else can help. I whipped up a picture of the variables and data you would need to make the program. Hope it helps.
------------------ |
||
Ereon Member Posts: 1018 From: Ohio, United States Registered: 04-12-2005 |
Just use a sprite rotation bit. Like, for instance, in DarkBASIC the command would be...
So what I would do is set it up like this...
What this does is assign the current angle of the sprite representing the bad guy to the variable enemysightangle. Then, the code calls the rotate sprite command, and rotates the "line of sight" sprite to the exact same angle. The end result is that the line of sight rotates with the enemy, without you ever having to make more than one frame. Since Blitz and DarkBASIC are so alike I'm fairly certain there is a similar command in BlitzBASIC somewhere. ------------------ Portia The Merchant of Venice |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Penny: I'm working on figuring out that one. I guess I'll eventually get it. Ereon: I don't know about DarkBasic, but BB uses Cartesian coordinates. But they start from the top right, without using automidhandle, it would rotate on the furthest top-right point. Secondly with AutoMidHandle it would rotate on the very center point. Thirdly The length of the sprite would have to adjust according to the objects around it. That is not available in BB. Fourthly, there is no Alpha setting in BB that I know of, and I need to have the objects underneath visible. ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
I just reread an earlier post, and am now responding. Continuation of Fourthly, I don't know how to make a sprite transparent without being invisible, and I want it visible to the player. ------------------ |
||
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
Now Mene Mene, if you are using Blitz3D, I know that image rotation in Blitz3D is kinda slow, so you probably want to make the already rotated sprites outside of Blitz. ------------------ [This message has been edited by LAVA (edited October 27, 2006).] |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
Mene, I've been thinking about you problem some more. Its forced me to learn a little bit of Blitz basic. Here is some pseudo code that might work.
P.S. I am using ^2 to square numbers (as in number * number) I'm not sure how to do that in blitz. ------------------ [This message has been edited by penny (edited October 27, 2006).] [This message has been edited by penny (edited October 27, 2006).] |
||
Ereon Member Posts: 1018 From: Ohio, United States Registered: 04-12-2005 |
Boy am I glad I use DarkBASIC...... ------------------ Portia The Merchant of Venice |
||
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
quote: lol, why is that? btw, check your PM's, Ereon ------------------ [This message has been edited by LAVA (edited October 27, 2006).] |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Thank you Penny! I am very grateful. Will look at it soon. ------------------ |
||
Ereon Member Posts: 1018 From: Ohio, United States Registered: 04-12-2005 |
It's any awful lot of hooplawing around just to make a simple "line of vision" ------------------ Portia The Merchant of Venice |
||
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
quote: Actually, you don't have to. I don't understand 99% of the methods presented in this thread, and I could make a line of sight easy. But this stuff just isn't my style. ------------------ [This message has been edited by LAVA (edited October 28, 2006).] |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Then whats your "Perfect" solution? ------------------ |
||
steve_ancell Member Posts: 37 From: Brighton, East Sussex, Southern England, United Kingdom. Registered: 09-16-2006 |
@ LAVA..... LAVA asked "Sounds like an interesting idea, except what would the pies do? Sorry, just a little confused"..... Ya wanna know what the pies do ?..... I think they go into the oven at about gas mark 5. LOL. Sorry, I could not resist that. ------------------ |
||
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
quote: Haha
quote:
quote: Is this a top down game by the way? If it is, my idea would be better suited for it. My idea up there is for a line of hearing. A line of sight? Just make it when enemy is at one rotation and you are at another and you are at a certain x and y distance make them go into an attack state or searching state, ect. ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Lava: Sorry for the way I acted, I'm just spending a lot of time working to learn this, and it sounded like you were making all my work out to be a waste, and I got emotional. How would you create the picture for this method? Yes this is a top-down game. I'm working on making this as professional as I can. Your method seems to me to not give me the flexibility, and the quality that I would need, not to mention efficency for coding as I would have 360 instances of points where the enemy could look. ------------------ |
||
Lava Member Posts: 1905 From: Registered: 01-26-2005 |
quote: Ah it's alright I didn't sense any hostility and you asked a legimate question Sorry if I sounded like I thought it would be a waste. I was just telling Ereon that you don't need a large equation to create a *simple* line of sight. Yeah, not much flexiibility. But Ereon mentioned a *simple* line of vision. ------------------ [This message has been edited by LAVA (edited October 29, 2006).] |
||
Ereon Member Posts: 1018 From: Ohio, United States Registered: 04-12-2005 |
Yeah, the one facet I see as your primary difficulty with the MUCH simpler bitmap collision is the alpha (transparency). I would suggest getting ahold of GIMP or some other decent quality 2D graphics editor and drawing a circle, then going and slicing the portions you don't want in your LOS or LOH away, but leave the image size the same. Then, after that, you go and export it as a gif or jpeg, or whatever image format you want that supports transparency and you're all set. It's not hard really, just takes some tinkering, and in the long run it'll be much easier than the trig based process. ------------------ Portia The Merchant of Venice |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Using the math formula, how am I supposed to the field to display? ------------------ |
||
dartsman Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
Just a question, anyone know what the dot product is used for?? lol, this sounds like an exact example of when to use the dot product (let along for back face culling, and also the fact that the dot product is the most used math’s calculation in games). Does blitz have a dot product function? If not it's trivial enough to make one... Vector2 is just a structure such as: struct Vector2 dotProduct would be a function such as (2d dot product, otherwise add similar to the z component): float dotProduct(Vector2 vec1, Vector2 vec2) Ok, so time for how to use it, and what it does. First what the dot product does... The dot product is used to get the angle between two vectors. This is most evident in back face culling. As you have one vector for the camera (camera direction) and then the other for the normal of a face (triangle), from those two vectors you can use the dot product to determine that they (the face to be more exact) are either facing the same direction (acute angle), facing opposite directions (obtuse angle), or perpendicular (right angle). So how does this work into your LOS issue? Well from the value returned from the dotProduct, not only can you quickly tell if they are roughly in front/behind a specific player, you can also, if you know that both of the vectors you pass to the dot product are unit vectors (sum up to equal 1), use the arc cosine on the result to get the exact angle (in radians). Now an example of how it is used:
I *believe* that would work, typed it up in MS Word so have no idea if it would compile/work right, let me know if there are any errors. Definitely look into Vector math if you are going to be doing a 2d/3d game… ------------------ |
||
AmazingJas Member Posts: 437 From: Sydney, NSW, AUSTRALIA Registered: 04-03-2003 |
My 2 bits. Firstly, Blitz 2D does not do transparency/alpha, however, this little library/extension will add the feature plus image rotations (and is the only way to do it in true 2D mode), plus many others features, but it does have minor drawbacks: http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=turtle177605192003023744&comments=no Alternatively, you could use dithering (filling say every 4th pixel with a grey dot). Doesn't look as good, but would do the job, especially if the line of sight/cones are only visible occasionally, like when you press a hotkey or something. Now for your problem, here is how I would approach it: 1. Calculate direction enemy is pointing Problem with this are that when your 1 and 2 values cross the 0/360 degree mark, you need to change your check slightly, but that's pretty easy to do. |
||
dartsman Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
dot product people... dot product... lol.... ------------------ |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
@Dartsman Dot products (best as I can remember) are a way of eliminating(more like hiding) trigonometric functions under the ruse of vector math It often simplifies the writing of formulas but equates to pretty much the same thing as trig functions. If you want to convert from polar coordinates(inherently angular) to cartesian coords (inherently scalar) you've gotta use trig. The relationship of the dot product is as follows from a snip from wikipedia: In the Euclidean space there is a strong relationship between the dot product and lengths and angles. For a vector a, a·a is the square of its length, and if b is another vector a·b = |a|*|b|*cos(theta) where |a| and |b| denote the length of vectors a and b, and θ is the angle between them. So, given a vector (b) that falls on an origin axis with a length of one, and given a vector with a length of the distance to the coord you want to find (a) referenced by angle from b. The dot product of a and b give you the coordinate on the axis b. So, if b falls on the cartesian x axis the dot product will return the y coordinate relative to the x axis, and if b falls on the y axis, the dot product will return the x coor (albeit inverted) relative to the y axis. Make sense? ------------------ |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
@Mene To display the field you would have to use line or polygon functions.. i'm not sure if blitz has these. But what you need to do is convert the enemy's FoV angles and distance to cartesian coordinates. Here's how you do that. The basic formula is: So given our variables above, this would translate to: FoVLeftX = SightDistance * cos(FoVLeft) BUT the problem is that assumes that the enemy is located at origin (0,0), so we'll add the enemy's coordinates like this: FoVLeftX = SightDistance * cos(FoVLeft) + ex Now do it for the right side angle of the Field of View FoVRightX = SightDistance * cos(FoVRight) + ex And we can do one for the FoV itself FoVX = SightDistance * cos(FoV) + ex And now we can make a polygon with the points: draw a line from ex,ey to FoVLeftX, FoVLeftY Its not a perfect pie, but a reasonable representation. If you want to make it perfect, calculate a point for each degree between FoVLeft and FoVRight and draw lines between them. Does that help? ------------------ [This message has been edited by penny (edited November 06, 2006).] |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Yes, It helps alot, I've gotten around to writing some code, but the FoVX, and the FoVY doesn't seem to be calculating right.
------------------ |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
Ah, FoV is just the width of the field of view. maybe try this instead for calulating FoVX and FoVY. FoVX = Sightdistance * Cos(EnemyFacing) + ex ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Works like a dream, how do I get it filled, and transparent though? ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Sorry for double post, but I had to share my new code that allowed pretty pies.
True, it has some sloppy techniques, but it only took 1 minute or 2. ------------------ |
||
MastaLlama Member Posts: 671 From: Houston, TX USA Registered: 08-10-2005 |
wow Mene Mene, good job on figuring it out! I've never used BB and the only way I could think of to do it (quickly anyway) was with pixel collision, but that would have been in GameMaker or Flash...not BB. |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
I don't totally understand yet the technics of Sine, and Cosine, but I understand what they do. The main Genre I do is RPG, and I couldn't figure out how to do that in GM, nor did I have the patience to figure out something in an "easier" to use tool that I can do elsewhere. I'm a bit worried at this point I'll have to rewrite everything when I reach BM. A way I could make the field is to draw lines from then enemyx to the other x's, but that would probably not be the best solution, and I still wouldn't know how to have transparency. ------------------ |
||
MastaLlama Member Posts: 671 From: Houston, TX USA Registered: 08-10-2005 |
something else you'll want to think about... what if you have the character against a box and the enemy is on the other side? their FOV would have to stop at the box... EX:
make sense? |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Yes, I was in fact going to this solution partly because of that fact. A sprite couldn't do that. I'll work on that once I get some objects working. ------------------ |
||
MastaLlama Member Posts: 671 From: Houston, TX USA Registered: 08-10-2005 |
commandos 3 did a really awesome job of this. Here's a link to some screenies and there may be a demo there somewhere: http://www.gamershell.com/pc/commandos_3/screenshots.html The only way I can think of to do this like so, would be to give each item (box, corner of wall, whatever) a 1 pixel line around it that will stop the vector drawn FOV, so it's still kinda using pixel detection. Although I'm sure there's other ways to do it. [This message has been edited by mastallama (edited November 07, 2006).] |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Mastallama: Couple of things, firstly I'm still confused on how to do the transparent shade. Secondly, how would I stop the drawing there? Some code would help I think. ------------------ |
||
buddboy Member Posts: 2220 From: New Albany, Indiana, U.S. Registered: 10-08-2004 |
wow those screenies rock. i admit Mene-Mene this is a pretty big challenge. hope you get it without a headache =D ------------------ |
||
Max Member Posts: 523 From: IA Registered: 09-19-2004 |
Just so you know, a lot of what you are wanting to do is like College level Calculus, heh. I didn't do so well in that class. Got a B. Had a D for most of it, lol. That's all I have, good luck! ------------------ Blind belief is dangerous. - Kenyan Proverb Computers are useless. They can only give you answers. - Pablo Picasso |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Thanks for the well wishes max. I'm still need of some help on making alpha shading within my pie. I think I got the math part done now. ------------------ |
||
dartsman Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
quote: Penny: Re-read my post, and you'd see that I actually explained what the dot product was, oh, and how to use it. I was jokingly saying "does anyone know what the dot product does??"... Trig is slow (how about add a sqrt call in there too?? lol), but I'm sure no-one cares... and please, no-one say that the dot product is "eliminating(more like hiding) trigonometric functions under the ruse of vector math". The dot product is the MOST USED calculation in GAMES. Do you even know how the magic of ‘backface culling’ even works? Have a guess… Dot Product... "ruse of vector math", what ruse?? What are you on about?? Vector Math is basic Games Programming Knowledge. Penny, what have you done? Games (hobby/professional)? Courses? ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
dartsman: I think we are talking in 2 different languages here. Why should I learn Dot Product/Vector Math over learning how to use trig. Besides, how does this sole my problem with creating a trasparent field? AmazingJas: So what is required for this plugin? How does it work? I've never done anything with UserLibs, and .dll. Would BM have transparency? ------------------ |
||
penny Member Posts: 101 From: Registered: 08-15-2006 |
@Darts Woah darts! I didn't mean anything offensive. I was simply trying to state that dot products are essentially trig functions from a perspective of vector math. (was joking about the ruse) According to the quick glance at the blitz manual it seemed like it only has trig functions, and they work in degrees, and in the limited amount of time I had to post, thought that it was easier to explain basic trig functions than a discourse on vector math. Especially since mene is just starting to get algebraic concepts down. All in all, I didn't mean to step on your toes. I know that you're the one with the game programming experience. I am just a humble writer and mathematician trying offer support to the CCN members. btw, wouldn't you still have to use trig (sine,cosine) to get the points coordinates to plot mene's pie? @Mene - I think what you are asking, is how to do a translucent polygon and it seems, unfortunately, that blitz does not support polygons or translucency. There are ways of manually doing translucency but i'm sure it would be very slow since you would have to read the pixel color from the screen and average it with the color you want to plot and then plot the average. And this would have to be done for each pixel in the pie. ------------------ [This message has been edited by penny (edited November 16, 2006).] |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Edited due to already being said. Penny: Yes, you are correct, I'm thinking about a translucent polygon. Maybe it should be mentioned that this is turn-based, and speed is (generally) not a factor? ------------------ [This message has been edited by Mene-Mene (edited November 16, 2006).] |
||
dartsman Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
quote: Because "Trig is slow"... meh, I do think I've just wasted more time... Dot Product is a less costly calculation then using trig... although trig might just be the 'simplest' means to an end... meh... I really don't care anymore.. ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
DartsMan: I realize I might have offended you, and I'm sorry if I did. I just want to learn what is easiest to learn, and I'm already partially through what I need to know of trig. Everyone: Ok, since it seems blitz can't do true transparency, could you show me how to cycle through each pixel within a field? ------------------ |
||
dartsman Member Posts: 484 From: Queensland, Australia Registered: 03-16-2006 |
well actually, trigs harder to visualise then vectors... anywho, if and when you go to do a uni degree or the like on games programming you'll learn it and all of a sudden it'll click Hope the project goes well. ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Darts: Thank You ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Okay, I'm working on making Vision in BM. I've found a "Draw Polygon" function, and am attempting to use that. Unfortunetly, its not working when I tested it by not writing in all the coordinates. The error message says: Compile Error. Unable to convert from 'Int Array' to 'Float Array' When that didn't work I tried copying it off their example, still didn't work. Here's the example code:
And here's my code:
I can't figure out whats wrong. ------------------ |
||
Lazarus Member Posts: 1668 From: USA Registered: 06-06-2006 |
Mene, even though you declare tri[] as a float array, I think you have to cast the variables you're putting in it into floats because as it stands they are integers. (Not sure though) |
||
samw3 Member Posts: 542 From: Toccoa, GA, USA Registered: 08-15-2006 |
My guess is that its here: Local tri#[]=[ex,ey,FoVLeftX,FoVLeftY,FoVRightX,FoVRightY,ex,ey] All those variables are not floats. It looks like a float in bm is referenced by a hash(#). Are there any number conversions functions? Something like CInt or CFloat? If so, wrap around each of your variables like this: Local tri#[]=[CFloat(ex),CFloat(ey)...] or, just work all your variables as floats like this: Local tri#[]=[ex#,ey#...] but you will have to change all the code above of course. ------------------ |
||
Lazarus Member Posts: 1668 From: USA Registered: 06-06-2006 |
There's a way to cast variables to different types in BlitzMax - I don't know the exact syntax though.(the reference manual is super-unclear.) | ||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Weird, I tried that before, but now it works. What ever. It works, and thats what matters. ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Sorry about double post, but I've finished my code. Soon I'll post it in the Code Samples. Here it is:
Question: Is there a way to make my "Local Tri" shorter using a loop or something? ------------------ [This message has been edited by Mene-Mene (edited January 31, 2007).] |
||
gaurdianAQ Member Posts: 106 From: Registered: 01-15-2007 |
I am just a novice programmer but here is my idea just create an invisible object around the enemies or character and when they collide then the enemies heard you or seen you | ||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
I've already gotten my solution by the way through Trig. Problem with that, is an Image can't change. ------------------ |
||
Lazarus Member Posts: 1668 From: USA Registered: 06-06-2006 |
quote: Shorter? I don't think so - it seems to be fine the way it is. |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
I mean, I'll have to type out all of the FoVX Array, and the FoVY Array. Is there a way to save me a bit of typeing and length? ------------------ |
||
samw3 Member Posts: 542 From: Toccoa, GA, USA Registered: 08-15-2006 |
sure, just assign them with a for loop Dim tri#(30) for i = 0 to 30 BM has c-ish syntax for arrays? i.e. brackets? [] not parens? () Normally basic uses parens to access arrays, so this syntax may be wrong, but you kinda get the idea. ------------------ |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
duh! I just forget with an open array, that you could do that. ------------------ |
||
Lazarus Member Posts: 1668 From: USA Registered: 06-06-2006 |
*is confused* [This message has been edited by Lazarus (edited February 02, 2007).] |
||
Mene-Mene Member Posts: 1398 From: Fort Wayne, IN, USA Registered: 10-23-2006 |
Laz: Why are you confused? It'd be something like this.
------------------ |