Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


blueshogun96

Member Since 09 Jun 2005
Offline Last Active Today, 03:29 AM

#5209535 How do I fix this stupid linker error?

Posted by blueshogun96 on 09 February 2015 - 12:02 AM

Okay, finally fixed it (thanks to Bacterius).

 

Changed this:

LOCAL_LDLIBS := -lopenal -lGLESv2

 

To this:

LOCAL_LDLIBS := openalsoft/armeabi-v7a/libopenal.so -lGLESv2

 

Sorry for cursing, I spent far too much time dealing with Android stuff then getting actual stuff done.

 

Shogun.




#5208344 1997 game graphic files

Posted by blueshogun96 on 03 February 2015 - 12:28 AM


Maybe one of you knows how sprites were stored in 1997 or recognized the file signature.

 

For starters, keep in mind that you can't assume every DOS game uses the same resource file format.  Usually they are custom designed to keep the every day person from easily reverse engineering it because devs generally don't want their assets stolen, so you could be infringing copyrights here depending on your intent.  Keep in mind that there are some exceptions, but you certainly cannot count on those either.

 

If you're really serious about this, then you might want to start off with building good reverse engineering skills.  Start by getting a good .exe disassembler and get a good knowledge of how x86 assembly works.  If you don't know assembly, then there may be a rather steep learning curve ahead of you.  I bought a book about reverse engineering, and it gives plenty of examples on reverse engineering functions in x86 assembly and discovering how code on a low level really works.

 

Shogun.




#5207766 Programming

Posted by blueshogun96 on 30 January 2015 - 04:42 PM

 

 

 

Listen to her.  She knows what she's talking about.

 

lol

 

 

That is the internet for you... Rule #37... the power of avatar images and game avatars. smile.png

Right.  I'm still amazed how many people (even staff) keep mistaking L. Spiro for girl, even though he's explained the story behind that sketch he drew multiple times.

 

Btw, to the person who just rated down that comment... Not to be a jerk, but FYI, given the above statement, please don't get it twisted.  I should have known that someone wouldn't catch the reference, and probably go "zomg misogyny"!  Or maybe I just wrecked someone's fantasy about L. Spiro being a girl. :)

 

Shogun.




#5207475 Programming

Posted by blueshogun96 on 29 January 2015 - 12:06 PM

 


Drop your project for your own sake and for the sake of the others working with you. It is not fair to them that their hard work go to waste just because their programmer (you) has no clue how to program but just decided to jump into the deep end foolishly thinking he could learn to fly before learning to walk.

 

 

 


But the advice on how to learn programming remains constant.  You still need to start with small projects and work your way up.

 

Listen to her.  She knows what she's talking about.

 

lol




#5206520 Windows 10 and Cortana

Posted by blueshogun96 on 25 January 2015 - 04:49 AM

Okay, so I'm porting my game to Windows Metro, because I believe it will be pretty well suited for it due to it's mechanics and minimalist art style.  And of course, I'd like to target Windows 10 and take advantage of some of it's exclusive features, such as Cortana.  Now, I've never actually used any APIs for Cortana before and I'm still rather new to writing apps for Windows Metro, but I think it would be a rather nifty feature to use in my game.  So far, every example I find is for Windows Phone 8, which is great in all because I'm supporting that too, but nothing in C++ so far.  Every example uses C#, and that's not the language my game uses.

 

So my question is (for those of you who are actively dev'ing with the Windows 10 preview), are the APIs basically the same between Windows Phone 8 and Windows 10?  And where can I find the APIs for C++?  All I can find is C# so far.

 

Thanks.

 

Shogun.




#5206259 I am beginning to hate the IT and gaming industry.

Posted by blueshogun96 on 23 January 2015 - 03:30 PM

Okay, 17 interviews later, finally got a new job.  It pays rather well for a position that doesn't require immediate coding ($70k). 

 

I guess I just had a Vegeta moment for a while there.

 

Shogun.




#5205696 I am beginning to hate the IT and gaming industry.

Posted by blueshogun96 on 20 January 2015 - 10:00 PM

Guess I was wrong, I'm through to the next round.  Got lots of studying to do.

 

Shogun.




#5204861 Porting my game to Linux

Posted by blueshogun96 on 16 January 2015 - 10:07 PM

2. It depends, if you stick to the LSB(you have to statically link any non LSB libraries, or replace them with a LSB equivalent) your game will run on all LSB compliant distributions (Using the LSB SDK is highly recommended), if you don't it is pretty difficult to say, it will most likely work on most debian based distributions atleast.

Thanks, but what does LSB stand for?

 

 


4. Any other helpful bits of advice.

You'll want to learn how to package your game distribution up as a .deb package. This is by far the friendliest way for your users to install your game on Debian/Ubuntu/Mint.

 

Ah, so it's a .deb that is the package type.  I've gotten used to having the all in one functionality of Apple's .app package.

 

While I'm at it, Ubuntu has an app store, and I hear that it's not working (or harder than it should be to install) on Linux Mint 17.  One of my goals is to get this on that distribution channel.  Do Mint users commonly have this installed?

 

Shogun




#5204851 Porting my game to Linux

Posted by blueshogun96 on 16 January 2015 - 08:06 PM

Recently, I've setup a VM of Linux Mint for the purpouse of porting my game(s) to Linux.  My game is already cross platform between Windows Desktop, MacOSX, iOS and Android/Amazon Kindle.  Now, I am quite familiar with Linux, but I've never dev'ed anything for it either.  So I was hoping to get a bit of advice from those who have done this before.

 

1. Will g++ suffice as my compiler?  My game uses C and C++.  I'm also a bit of a noob to makefiles...

2. Since Linux Mint is based off of Ubuntu (and in turn, based off of Debian), what Linux distributions will my game run on then?

3. My game uses GLUT (and I plan on switching to freeglut), do I have to install anything extra or does Mint come with this?

4. Any other helpful bits of advice.

 

Thanks.

 

Shogun.

 

EDIT: Figured out how to install freeglut, and got it working with g++ already.  That's a load off so far.




#5204167 I am beginning to hate the IT and gaming industry.

Posted by blueshogun96 on 14 January 2015 - 03:23 AM

Fair enough Mr. Sloper.  I guess I can't argue with that.

 

This is a non-gamedev position, and I still have no more interest in working for gamedev companies anymore.

 


By the way, in your "outside-of-industry experiences", did you work with a team (of indie developers, for instance?). I do think teamwork is effectively what makes a team productive. Someone with mediocre programming skills but excellent teamwork skills will still create better results than an excellent lone genius programmer.

Yeah, but nobody cared about it (Cxbx).  In fact, it just confused employers even more, so I removed it. 




#5204067 I am beginning to hate the IT and gaming industry.

Posted by blueshogun96 on 13 January 2015 - 05:06 PM

 


You seem to make it very personal and also have a hetz against Microsoft. Given your explanations it's easy to call it a sob story but you have to remember that everything is just business, nothing personal.

 

Maybe you should try and seek out startup companies?

Companies that can't expect to get the veterans right off the bat, companies that doesn't have the infrastructure of a giant, and so forth. This could benefit you a lot to break into the industry. Otherwise you would have to look at options, as mentioned earlier, like making your own company and start that way.

I see little to no difference with startups, as the bars for getting in appear to be just as high.

 

With this statement you are sort of proving that you have become very biased and jaded.

 

The world is not so black and white. Try look around on Elance (as mentioned earlier), the Unity Forums, the Unreal Engine Forums, the Gamedev Forums, the IndieDB forums, and the list goes on. You have so many possible job positions and the industry is hurting for programmers (as it always is!). Programmers are usually in high demand, as we tend to find an ocean of differing artists (we had to look for 6 months ourselves to get a programmer).

 

You also have another option. Try get your hands on for example, Unity or Unreal Engine (both very accessible and pretty easy to get into) and then start building prototype games that centers around one single mechanic or few very simple mechanics. Start gaining knowledge on how these engines work (like for Unreal Engine you get access to ALL source code. Everything!) and then try and extend their frameworks and prove that you are as good a programmer as you say you are. Then build a portfolio of these examples and start seeking out Indie Studios as you are much more likely to get in. Even if you just have to send an unmotivated application.

 

The world is not so black and white smile.png

 

 

You're god dang right I'm biased and jaded!!!  And I think I have every right to be so.  Hence the recent and appropriate avatar change to reflect it.

 

If they're hurting for programmers so dammed bad, then why haven't they hired me yet?  And quite frankly, as I stated earlier, I never want to work for a game company ever again.  I'll go ahead and try Elance, since I've never heard of it.  Almost everything on CL.org is a bust anyway.

 

I'll take your advice on other frameworks, but for non gaming frameworks, like Cordova, Ionic, AngularJS, Gulp, Selenium Webdriver, and other things related to web dev.  Although I really hate trying to cram in knowledge for the sake of appeasing someone else.  I applied for a smaller company that's more at the startup level like you all said, but I have my doubts.  I'm sorry, but I'm just not convinced.  For me, everything is the god dang same!

 

Not trying to play the race card, but I am black, and the world is white.  So, in a literal sense, it is black and white.  And it's still f-ed up. 

 

It's easy to be overly optimistic when you have a job already, have no major obstacles getting one, or have lots of experience to help you find another.  At one point, this becomes unavoidable.

 

Shogun.




#5203912 I am beginning to hate the IT and gaming industry.

Posted by blueshogun96 on 13 January 2015 - 07:44 AM

I never thought I'd say this, but I guess I'm finally getting to that point.  This industry is so ridiculously cut throat and unforgiving, that it's amazing that people are so willing to tolerate it.  That's my opinion of both gaming and non-gaming companies alike.  I don't expect everything to be perfect, of course, and certain things can apply to nearly any industry.  So, if you would, please sit back and I'll tell you about my experience in this industry so far.

 

1. Gaining Experience

We're all familiar with the most common catch 22, right?  No experience == no job, and no job == no experience.  When I came back to Washington, that was my situation.  Being in dumb 'ol Indiana for 16 years was a real set back; no IT opportunities, let alone any way to gain any real experience.  So, I took what I could get.  I was once told that any experience is good experience, and that if I started off in QA, then I could work my way into the dev side.  Of course, that didn't pan out so well.  With all of these manual QA positions on my resume, I was seen as a tester.  A tester who was probably skilled at it because I obviously had so much experience.  I quickly learned that too much QA experience is not so great when looking to break into something coding related, which I'll get to in a moment.

 

2. What Counts as Experience

Another thing I learned is that virtually nothing that's done outside of the professional world counts as experience.  It never mattered that I wrote a complex engine, or collaboratively worked on and devised one of the most complex Windows emulator programs ever to exist.  It was all about "what have you done in company X, or what have you done that generated capital?".  Not trying to gloat, but for years, I have people telling me how they are jealous of my coding skills, and wish they could reach my level.  They also say that they are surprised that I cannot get a dev position anywhere and that they wish they could hire me because they have seen what I'm capable of.  Tbh, I don't believe I'm all that great, but to someone else, I am; based on results.  I stopped letting this bother me, because I had bigger issues to worry about.  See the next paragraph.

 

3. Experience == Skill?

After my resume began to get bloated with QA positions, as stated earlier, I'm seen as an average manual tester with no real technical skill beyond that.  So based on that, I was continuously misplaced in positions that did not fit my skill set.  I did not have the mindset of a standard issue QA person; never did, never will.  In fact, I can honestly say that I wasn't really that great at it either.  It sounds easy, but from a mental standpoint, it was actually harder for me considering the way my brain works (keep in mind that these were mostly game testing gigs).  Even though I began to improve, it was never really enough.  Many of my co-workers could tell that I was better suited for dev, and tried to encourage me, but of course I still crashed and burned in the end.  Game testing was among the worst things I've ever done in the industry, and I have a deep distaste for it to this day, although it has to be done.  Of course, I blame my lack of maturity in certain situations and in many situations, I have no one to blame but myself.

 

4. Keeping Up

Every job and company is different, and tend to have different expectations in terms of performance, workload, etc.  My 2nd experience at Microsoft was undoubtedly the worst, although the 1st one was considerably better.  Back when I did UI testing for 360's dashboard, everyone was monitored for performance.  If you could not meet a specific quota within a certain amount of time, they were already looking for your replacement, and often with little notice.  I could tell that I was not going to make it on that 2nd position, so I saw it coming.  Even when doing my very best to focus and get the job done, I could never get X number of test cases done within a specific time period, and as a result, I was essentially "less privileged" and got more dirt.  Once I got literally yelled at because I got confused.  If I hadn't been able to control myself, I'd have probably yelled right back, then stormed out of the office because I was so pissed.

 

This wasn't always the case.  When I worked at a company called Bsquare, where I was an automation engineer for Blackberry devices, it was very smooth and laid back.  I was able to get all of my work done on time, and never had any issues with management, nor was I constantly being badgered about performance compared to others.  The best part was that there was no competitive nature.  It was undoubtedly the best company and best position I ever had the pleasure of working in.  But when RIM (Research In Motion) was sold off, the company took a different direction, and as a result, I was laid off and my contract was terminated.

 

As far as performance goes, sometimes it was my own inability to stay focused on non-coding tasks, so I can blame myself for this pattern in some places, notably my first two positions in the industry.  The 2nd two were a bit more ridiculous.  But enough about that.  These are things that I probably could have had more control over in one way or another, if I had been a bit more mature.  The rest I'm about to mention is out of my hand(s) for the most part.

 

5. Pay and Worth

Eventually, I did work my way up to the ranks of SDET.  It took a long time, but I had finally broken out of the manual test loop, which was kinda like Izanagi.  I don't know how I did it, or how such an opportunity arose, but it happened and I did it.  I was an SDET at Amazon, and it felt great.  Not quite the same as Bsquare, but I liked it.  Although there was one major problem I had with it, and it was the fact that I was being paid less than others based on GPA in college.  Initially, I was being quoted $10k more than what I was making, then they dropped it down with that difference, but I still accepted it because I wanted so desperately for a job that involves coding.  It was bad enough that I wasn't making what other SDETs were making for the same work based on that, as if my skills didn't matter...

 

6. Cheapest Person Possible

This one kinda obvious.  Employers want to have the best employees for the cheapest payroll.  Kinda like above, they want the most qualified people, but will try to pay you less than what you're really worth in many cases.  The biggest rip-off IMO is where they say they want a junior level candidate, but instead hire the most senior person that they can find who's willing to work for less.

 

7. References

Sometimes, it can make or break you.  This is the story of how it broke me in the most BSed way possible.  I had an interview with Microsoft as an SDET for WP8.  I passed the interview, and even the dreaded whiteboard with flying colours, all on my first shot.  I would have gotten the job, if it weren't for one thing: a reference.  They wanted a reference for that ONE time where I tested some games on a Windows Phone 7 years ago.  I tried to tell them that this was only once, and at an ON CALL job with a very high turn over rate, so there was no way I could provide a valid reference because not only does that test lead not work there anymore, I never knew his name either.  In fact, none of the leads I worked with were there anymore (at least, none that I knew).  I kept trying to tell them this, but unfortunately (not trying to be racist, but) I was dealing with someone from India, and we had a communication breakdown because of the language barrier.  So, they assumed I was bluffing about it, and refused to give me the job.  Nevermind that I've proven to them that I can dev for the WP8, they just wanted that measly testing reference of a phone I tested ONE friggin time!

 

8. The Interviewing Process

Now this is what really bothers me.  The one thing I hate most is actually getting a job. 

 

Most of my angst involves the whiteboard.  Regardless of whether I like or hate it, it's been a big obstacle.  When I'm asked to write some mundane algorithm on a board, I know that this is either going to make me or break me; one mistake, and kiss your chances goodbye.  What I learned is that even if I do make it to the interview, if I make one little mistake on that whiteboard, then I will not get the job.  And what I mean by mistake is not fulfilling the algorithm to the interviewer's satisfaction level.  This has happened multiple times, where I wrote a perfectly good function, but because they didn't like they way I did it specifically, they chose not to hire me.  The only times I've ever gotten a job (or should I say, passed the interview) is where I completed the coding problems perfectly, and on the first try I might add (having to fix anything will cost me the job E-V-E-R-Y time)!  I'll save my last whiteboard story for last.

 

Another issue I have is when an employer suddenly expects greater qualifications, or doesn't tell you about it until AFTER the interview when you didn't meet their hidden requirements.  This has happened multiple times, and one of them was Microsoft.  If they wanted someone with experience in X, they should have said so before!  And then they're surprised that I don't meet their requirements.  Once, I was told to write X in Java using X framework, one that I was not familiar with, so they moved on, and they eventually asked me to do something else I was not familiar with, or wasn't told about on the job description.  So then he was like "Okay, I've got nothing else.  Do you have any questions for me?"  I wanted to say "No, because I already know I'm not getting the job", but I didn't want to be rude either.  I mean really, they didn't even offer to pay me more!  Microsoft pulled a similar stunt by asking for a lead SDET, but wanting to pay this person $36/hr.  This alone was insulting (L. Spiro was appalled also), but I tried for it anyway.  So, after the interview, I was told by my recruiter that I didn't get the job because I was not someone with lead developer experience, and that they have been very choosy with their candidates.  Like I said before, they should have said that in the job description (not even the recruiter knew) and if they seriously want a lead dev, $36/hr is a VERY weak salary to offer, but that's Microsoft for ya.  They always pay people less than what they could make elsewhere (in my experience at least).

 

Once, I essentially was insulted by the hiring manager of Sirius, seriously (pun intended).  Essentially calling my life's work crap, he said that I have no programming experience or skill.  Fortunately, there was a wall between me and this hiring manager, and my recruiter was that wall, preventing me from telling him off.  If I wasn't like SoTL, I'd have cursed him out too.  My recruiter wanted to tell him off also, but instead she respectively withdrew from this opportunity.

 

There's more bogus stuff about interviewing I could say, but I want to wrap this up with one more; intentional lack of feedback.  This has also happened more than once.  One ended up in going home with a broken iPhone (which set me back $75 and much personal dev time).  This is when I interviewed at Epic.  I won't get detailed about this one because of the NDA, but it's kinda strange how they seemed to want to hire me and admired my skills so much, and then refuse me while refusing to state why.  The broken iPhone was my only issue (it fell out of my backpack), but the last one was the interview that caused me to snap.  I was interviewing for a company with an outdoors theme, and my recruiter could tell that I wasn't feeling too sure about the interview.  He told me that this company often is very accepting of those who aren't the most senior level of devs/SDETs.  So I take his word for it and do my best.  I'm given a white board problem, one that I'm told that I will not finish in time, so just do my best.  So I choose a totally new approach to the whiteboard instead of blindly jumping in.  As a result, I got further than most people do on average (that's what I was told) and that I did rather well.  In fact, the lead SDET/dev guy told me that he hopes I get hired (secretly, of course).  The interview had two parts, and the whiteboard was with a totally different set of people, so I have no idea what I did right/wrong on the other end.  Ultimately, they decided not to hire me, and also refused to state why.  This is irritating because then I can't improve myself for the next interview.

 

9. Continuous Long Term Unemployment.

And finally, I realized that as a contractor, finding the next gig can take more time than I can handle.  Getting a permanent position is really hard, if you're not senior level.  So my chances are best with a recruiter.  A given contract is never guaranteed to last as long as I'm quoted, and so far, my contract ALWAYS ends earlier, then I have to go months before I can find a new job.  Because of this, my employment history is a bit fragmented, and it's hard to fill in the gaps, since personal experience outside of work doesn't really count to employers.  During my biggest gap, I ended up being homeless for 2 years (not living under a bridge, but in transitional housing because finding consistent work was really hard to do; and believe me, I tried applying for blue collar jobs too).

 

My last job ended in September of last year.  4 months and 14 interviews later, still no job.  This isn't to say that it's all their fault because I do examine myself and I'm aware that I'm not always the best person for the job.  This is really getting old, and I'm really getting tired of this crap.  Quite frankly, some of my blue collar jobs have treated me better than the IT industry has, and my last Microsoft experience has literally been a white collar sweatshop because the office I was in had no AC during the hotter seasons, except for one small AC vent that was located by the lead's desk.

 

TL;DR, the IT industry has been very brutal and unforgiving.  Life isn't fair, but this is just ridiculous.  Tbh, I never want to work for a game company ever again (unless I'm running it of course), and I'm beginning to think the same thing about non game companies also.  I'm also beginning to think that it isn't worth all of this trouble.  Seriously, how do you all put up with this?  This isn't meant to be a sob story, I'm just running out of ideas, and patience.  No, scratch that, I'm fresh out of patience.  Pardon my French, but

 

1351870957597_1301103.png

 

A peaceful life in the mountains of western Hungary is sounding nicer and nicer by the day.

 

Shogun.




#5198182 Bullet hell projectiles as separate objects? Or as one whole particle system?

Posted by blueshogun96 on 14 December 2014 - 02:21 PM

I've written bullet yells before, but my coding style was very inefficient my first time around. Initially, I used pure C and linked lists, which was a bad idea because since the memory in a linked list is not contiguous, it results in a greater number of cache misses, which is a performance drainer.

Not sure what language you are using (assuming C++), but a growable heap should work fine. IIRC, std::vector handles this nicely. You can even reserve a specific size beforehand, and it will handle the heap sizing for you. If your bullet is a class, you can simply have a base class and subclasses inheriting from it with unique mechanics.

If this is your first time, you'll actually discover that writing bullet patterns is actually easier than it sounds. If you know trigonometry and how to make an object move in a specific direction and at a variable speed, then you've got what it takes! My ex coworker asked me about this, and I explained to him how easy it was.

I don't claim to be the best, but feel free to ask me if you need help. I love coding for this genre of games.

Shogun


#5198168 Optimizing an HTML5/Javascript Game

Posted by blueshogun96 on 14 December 2014 - 01:09 PM

I have an HTML5 version of my game that I've been working on (primarily as a demo for browsers and mobile).  So far, it's working but I still have speed issues, primarily with Firefox.  Other browsers generally work fine (with occasional oddities), but considering that Firefox is still a popular browser, I have to support it.

 

This is my game: http://looptil.shogun3d.net

 

You can view the source code from the browser, or you can read it directly here: http://looptil.shogun3d.net/js/main.js

 

Known issues:

- Sometimes the trail has 'knots' in it, this is a bug with curve.js AFAIK.

- Audio latency in Safari.

- Slows down on particle effects.

- .wav files not supported in IE (will fix today).

 

Any other suggestions for speed/compatibility improvement?  Thanks.

 

Shogun.




#5193926 Line intersection algorithm?

Posted by blueshogun96 on 21 November 2014 - 01:28 AM

So, I'm in the middle of porting this algorithm from C++ to Javascript.  The biggest challenge is this line intersection code.  Sometimes it works, sometimes it doesn't.  In C++, it works fine, but for Javascript, it only works half of the time.  Since I still have lots to learn about Javascript, any other advice is welcome.

 

These are the relevant parts of the code:

function add_trail()
{
    /* Add a new line */
    var t = new trail_t( user.x, user.y, user.lx, user.ly );
    trails.push(t);
}

function identical_points( t1, t2 )
{
	var t1p1 = { x:t1.x1, y:t1.y1 };
	var t1p2 = { x:t1.x2, y:t1.y2 };
	var t2p1 = { x:t2.x1, y:t2.y1 };
	var t2p2 = { x:t2.x2, y:t2.y2 };
    
	if( t1p1 == t2p1 ) return true;
    if( t1p1 == t2p2 ) return true;
    if( t1p2 == t2p2 ) return true;
    if( t1p2 == t2p1 ) return true;
	
    return false;
}

function handle_trail_intersections()
{
    ...
    
	for( var i = trails.length; i--; )
	{
		for( var j = trails.length; j--; )
		{
			/* Do both of these lines already intersect? */
			if( trails[i].intersection && trails[j].intersection )
				continue;
			
			/* Do the lines have matching points? */
			if( identical_points( trails[i], trails[j] ) )
				continue;
				
			var p1 = { x:trails[i].x1, y:trails[i].y1 };
			var p2 = { x:trails[i].x2, y:trails[i].y2 };
			var p3 = { x:trails[j].x1, y:trails[j].y1 };
			var p4 = { x:trails[j].x2, y:trails[j].y2 };
			
			/* Check for an intersection */
			var intersect_point = check_for_intersection( p1, p2, p3, p4 );
			
			if( intersect_point.positive == true )
			{
				trails[i].intersection = true;
				trails[j].intersection = true;
				
				...
			}
		}
	}
}

And the actual line intersection function:

function check_for_intersection( p1, p2, p3, p4 )
{
	var intersection_data = { x:0, y:0, positive:false };
	var x = [], y = [];
	x[0] = p1.x;x[1] = p2.x;x[2] = p3.x;x[3] = p4.x;
	y[0] = p1.y;y[1] = p2.y;y[2] = p3.y;y[3] = p4.y;

	var d = (x[0] - x[1]) * (y[2] - y[3]) - (y[0] - y[1]) * (x[2] - x[3]);
	
	if( d == 0 ) return intersection_data;
    
	// Get the x and y
	var pre = (x[0]*y[1] - y[0]*x[1]), post = (x[2]*y[3] - y[2]*x[3]);
	var X = ( pre * (x[2] - x[3]) - (x[0] - x[1]) * post ) / d;
	var Y = ( pre * (y[2] - y[3]) - (y[0] - y[1]) * post ) / d;
    
	// Check if the x and y coordinates are within both lines
	if ( X < Math.min(x[0], x[1]) || X > Math.max(x[0], x[1]) ||
        X < Math.min(x[2], x[3]) || X > Math.max(x[2], x[3]) ) return intersection_data;
	if ( Y < Math.min(y[0], y[1]) || Y > Math.max(y[0], y[1]) ||
        Y < Math.min(y[2], y[3]) || Y > Math.max(y[2], y[3]) ) return intersection_data;
    
	intersection_data.x = X;
	intersection_data.y = Y;
	intersection_data.positive = true;
    
	return intersection_data;
}

So, do you think it's the line intersection function?  Or is it the way I'm handling the lines?  The trails[] list forms a line strip using the user's current and previous positions, and the goal is to detect when the lines are intersecting.  Once again, in C++, this works fine.  Not sure why it's problematic in Javascript.

 

On a side note, I'll get rid of the nested for loop later.  I didn't think about it until after writing the implementation.

 

Any ideas?  Thanks.

 

Shogun.






PARTNERS