Collision Detection Not Working - Causing Infinite Loop

Jan 18, 2010

I cant get collision detection to work. I tried but it always caused an infinite loop.

Heres the code.
<html><!-- main file.--><head>
<title>lightning generator</title>
</head><body>
<canvas id='world' width='500' height='500' style='border: 1px solid black; padding:0;'>
</canvas><script type="text/javascript" src='world.js'></script>
[Code] .....

In the end of world.bolt.cpath,there should be a way to use the local varis X and Y, and world.ground.js's world.ground.level[] to detect it. sorry for the gigantic length.

View 1 Replies


ADVERTISEMENT

Still Have Problems With Collision Detection

Aug 30, 2006

So I temporarily gave up on my breakout game (code) due to getting frustrated and a short trip, but it's time to finish it. After all, this is the only thing that's left to fix/do. The ball does not bounce correctly off the sides (the code in the checkBlocks function). It only/always seems that the first if statement evaluates to true, and when it gets to the second if statement, it doesn't evaluate to true because the other one already reversed the ball's direction. So how can I correctly determine where the ball came from?

Also, sometimes the ball gets stuck. For example, if you happen to hit the ball with the paddle in the bottom left corner, the ball will bounce back and forth along the left side of the board. I'm not sure how to fix this either.

View 6 Replies View Related

Can't Get Infinite Loop To Stop?

Mar 19, 2010

I was making some error checking... and well for some reason its not liking me...

<html>
<table border="1">
<tr>[code].....

View 2 Replies View Related

Escaping Infinite Loop

Jul 24, 2006

I would like to create an image "slideshow" for which I am using the following loop:

<script type="text/javascript">

intImage = 22;
function swapImage() {
if (intImage >= 22) {
intImage=1; }
else {
intImage++;
document.getElementById("IMG1").src = "images/P"+intImage+".jpg";
} }

intImage = 1;
function swapImageback() {
if (intImage <= 1) {
intImage=22; }
else {
intImage--;
document.getElementById("IMG1").src = "images/P"+intImage+".jpg";
} }

</script>

The problem with the loop is that it's infinite, which I understand is generally not a very clever solution. In this particular case I would like to escape the loop with P20 and then link to a new page.

View 2 Replies View Related

Infinite Loop Through Images?

Jun 11, 2011

I am trying to do the following: I have written a simple programm that loops through an array of images when the user clicks a button. I have used a for loop to do this. The program works fine, however when I get to the end of the array, the condition created in the for loop is "true" therefore the button no longer changes the image. How do I start the loop again to create an infinite loop (i.e. every time the button is clicked, the image will change)?The script I have written is as follows:

var mySpheres=new Array("sphere.gif","sphere2.gif");
function changeSphere(){
mySphere=document.getElementById("sphere");[code]....

View 5 Replies View Related

Popup Calendar Seems To Have An Infinite Loop Somewhere?

May 3, 2011

That's right folks, it's your favorite noob again. I am working on a popup calendar, and it is almost finished. The problem I am running into, is there seems to be an infinite llop somewhere in the cell creation. i have attached a snippet of the popup calendar as it currently is produced. As usual, I have spent the requisite 2 hours staring at my code. I found a few things, but I am now stumped.Here is my code, let me know what you see.

<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" "http:www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http:www.w3.org/1999/xhtml">

[code]....

View 2 Replies View Related

Infinite Loop When Replacing Ampersand?

May 3, 2010

I have a function that takes the input from a text area, searches through the text, and should replace &, ", <, or > with &, <, etc. As the code is now, it will replace other characters, but runs into an infinite loop when dealing with ampersands.I'm thinking it's finding the ampersands from other things it has already replaced and trying to replace them over and over.how to improve this and break out of the loop?

Code:
<script language="javascript">
function replace(){[code].....

Here's a link to try it out, but the loop is infinite if you search for an & and may crash your browser.

View 2 Replies View Related

Infinite Loop Page Reload?

May 2, 2011

I have a problem of an infinite loop.The problem is found at:

http://truth-and-opinion.dyndns.org/BoR/

This page was created with minimal script, taken out of a larger more complex page.The body element is set with the onload attribute which calls a handler to initialize the content. In particular, I want to initialize the URL with a query substring: "?p=X" where X is a number from 1 to 10, corresponding to pseudo-page content. This is done by setting the page URL with the location.search property.But the problem with this appears to be that setting the location.search property causes another onload event, which then calls the initializing handler and sets location.search property again.

Setting a global such as locSearchInProgress to a boolean and testing if it is true within the initializng handler to cause it to return and thus to prevent execution of the location.search assignment statement is not helping.I have tried using .stopPropagation() and .preventDefault() methods while developing in FF, but have been unsuccessful.Is there a way to update the URL using a location.search assignment without triggering onload?

MORE INFO

What is a "pseudo-page"? There is actually only one HTML document (index.html), and it has ten DIV elements that are NOT displayed (CSS property "display:none"). After the user initiates a click event on the part of the document that is an interface for content / pseudo-page selection, any one of the DIV elements can be called using document.getElementById(), and its content put into a DIV that displays the content using a contentNode.replaceChild().Thus page navigation is script-based using hidden content fetched into a visible container.

View 2 Replies View Related

JQuery :: Infinite Loop Inside (string).text()

Apr 26, 2010

The following sentence makes jQuery hang up: $(":( We'll this activated :D").text()

View 4 Replies View Related

JQuery :: Animate Callback Scope For Infinite Loop?

Jun 7, 2009

I'm trying to create an endless animation similar to a screen saver, here an image floats around the screen, fading in and out. I would like to stay out of the global namespace, so I'd like to use the callback to animate() rather than getTimeout(), which seems to operate only on functions in the global namespace. Please correct me if I'm wrong about that. But I'm having trouble maintaining the scope I want for the callback I want "this" to refer to my Animation object, not the HTML element. I understand many folks have solved this problem for events by using bind() or live(), but I am wondering how to do this for animate().

[Code]...

View 8 Replies View Related

JQuery :: Infinite Loop Alert On Combing Jcarousel And Google Map?

Jun 2, 2009

I have some problems about using jcarousel library on Google Map, and following is my scenario: there is a Marker on the Map, and when clicking on the Marker,Info-Window will pop up, and jcarousel content will be in the Info- Window And This is a simple demo:

[Code]...

View 1 Replies View Related

JQuery :: Call To FadeIn() Within A Loop Causing Page To Scroll Up?

Feb 18, 2010

I am using a timer to fadeOut and fadeIn some articles such that 5 articles are displayed in rotation.However, for some reason the call to fadeIn or fadeOut is causing the page to change it's y scroll position. If I am currently at the bottom of the page, the fadeIn call causes the page to scroll up.

View 2 Replies View Related

Browser Detection Not Working Correctly / Solve This?

Mar 20, 2010

I have an html form where IE and Firefox work very differently. So, it'd be useful to know what browser is in use. I found this script and put it in my html code...

In the php I do a echo code... but it's always empty... I figure I've got something obvious goofed up, but what?

ALSO, when I run it in IE 8.0, on screen it says "Microsoft Internet Explorer", but it SAYS Browser version: 4 - But I'm using version 8.

AND, when I run it in Firefox version 3.5.5 it SAYS "Netscape" and Browser Version: 5.

View 2 Replies View Related

Browser Detection For Expanding Width SELECT Column - IE Not Working (JS And HTML)

Aug 6, 2010

[URL]If you go to that site on Firefox, the "Return Code #" expands. But if you use IE, you'll see that it doesn't.I could add a fix in there for the fields if they were static, but if you see my javascript, they are dynamically loading fields.

This "class":"wide" is not working:

Code:

invoiceInput.appendChild(createElement("input", {"type":"text", "name":"invoice[]", "size":"8", "class":"wide;"}));

I am using a script I found on a jQuery board [URL] and it works for them, but not for me because my syntax is probably wrong. And they also are just using 1 field and not near-unlimited dynamically loading fields like I am.How would I add in a fix to have the browser 'only' use the expansion if the user is using IE6 or IE7?

View 1 Replies View Related

Browser Detection For Expanding Width SELECT Column, IE Not Working Right.(JS & HTML)?

Aug 6, 2010

[URL]...If you go to that site on Firefox, the "Return Code #" expands. But if you use IE, you'll see that it doesn't. I could add a fix in there for the fields if they were static, but if you see my javascript, they are dynamically loading fields. This "class":"wide" is not working:

Code:
invoiceInput.appendChild(createElement("input", {"type":"text", "name":"invoice[]", "size":"8", "class":"wide;"}));

I am using a script I found on a jQuery board [URL]..and it works for them, but not for me because my syntax is probably wrong. And they also are just using 1 field and not near-unlimited dynamically loading fields like I am. How would I add in a fix to have the browser 'only' use the expansion if the user is using IE6 or IE7?

View 3 Replies View Related

Object Detection Vs. Browser Detection

May 5, 2003

I'm going to make an attempt at coding a nice tree menu that is decent with browser support.

I want the tree to be displayed on all browsers (well, within a decent range). Of course, on older browsers, the menu won't be as functional.

Now, I'm going to be combining the javascript with a server-side language (asp.NET) and I'll be able to do some basic browser detection on the server.

But, I read about javascript object detection and am wondering how well that works exactly.

Like, what if a browser that doesn't support objects period tries to run some object detection code? Also, which browsers support user defined objects?

See, I'm thinking of breaking down the script in 3 categories. Browsers that won't get any javascript... these would be the browsers that don't support object detection, browsers with basic javascript... with these I would be able to code my own object and I would test for different features. And then there would be the browsers that can run it all.

So, basically, my question is what browsers support what features and how should I break down my code between them? A long time ago (back in the Netscape 4 / IE4 days) I did some javascripting, but since then I haven't really done any. I remember that NS4 didn't support div tags but supported layers... anyway, it got really messy.

View 4 Replies View Related

JQuery :: Fancybox Links Within A Jshowoff Slide Causing Fancybox To Stop Working?

Oct 17, 2010

I've been working on a freelance design site, and I have been using jshowoff and fancybox on my portfolio page. The portfolio has multiple sections that are set to be scrolled through using jshowoff by using the slide links. This use of jshowoff is working perfectly fine, but fancybox isn't. fancybox is supposed to be set to launch a modal when any of the portfolio thumbnail images are clicked. As it is right now, fancybox links will not work within the jshowoff slide div, but they do work outside of the jshowoff slide div.

I have done about 5 hours of searching online for possible fixed to my issue, and I haven't found anything. I am attempting to fix the conflict the between jshowoff and fancybox. I am very new to using jQuery plugins, so hopefully, you can all bear with me.If anyone may know how I can fix my fancybox links, so that fancybox will work within my jshowoff slide, I'd greatly appreciate it. I have provided the html below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

[code]....

View 2 Replies View Related

Creating Frogger Game - Collision Of Objects

Mar 16, 2010

I am creating a frogger game. When the frog image collides with a vehicle image, I wish for the frogs position to be reset back to the start. Here is my code which is currently not working:

Code:
// Frog Collisions: (CURRENTLY NOT WORKING)
var cvehicle=new Array(0,
document.getElementById("car1"),document.getElementById("lorry1"),document.getElementById("car4"),document.getElementById("lorry2"),document.getElementById("car2"),document.getElementById("car3"),
document.getElementById("lorry3"),document.getElementById("car5"),document.getElementById("car6"),document.getElementById("car7"),document.getElementById("car9"),document.getElementById("car10"),
[Code] .....

View 3 Replies View Related

JQuery :: Modifying Splatter Plugin To Avoid Collision/overlap

May 25, 2011

jQuery Splatter by Cory Schires

I was looking for something that would allow me to scatter elements (divs w/ background-images) behind text. Splatter is almost what I want, but I would need:

- no overlap in the positioning of elements

- keep the elements inside the container

- remove the default asterisk completely

As I have varying article dimensions, this keeps the splatter area the right size:

Code:

height: $("#article-text").height(),
width: $("#article-text").width()

Could the collision detection code in jQuery UI Position be used somehow?

View 1 Replies View Related

JQuery :: Modifying Splatter Plugin To Avoid Collision/overlap?

May 25, 2011

I was looking for something that would allow me to scatter elements (divs w/ background-images) behind text. Splatter is almost what I want, but I would need:

- no overlap in the positioning of elements
- keep the elements inside the container
- remove the default asterisk completely

As I have varying article dimensions, this keeps the splatter area the right size:

Code:
height: $("#article-text").height(),
width: $("#article-text").width()

Could the collision detection code in jQuery UI Position be used somehow?

View 1 Replies View Related

JQuery :: While-loop - Working Only Once

Jul 21, 2010

I have while loop, where something is defined via ID, I called it pin_click.

So of course there are a few entries.

And I have the following Code:

Somehow, this Code only works for the first element, I get out of the while loop. The other elements of the while loop ( which have the same Button ) are just doing nothing, even no action in Firebug.

View 6 Replies View Related

Loop Working Once But Not A Second Time?

Oct 6, 2009

I have a form on my page that gets checked and verified with a bit of AJAX and then gets sent off if all is good, but I also created a quick little loop to verify that all the fields are still full and completed before sending the info off to the server officially .here is my test page for the loop that i have created.

PHP Code:

<html>
<head>
<script type="text/javascript">

[code]...

Now the loop works great if you test it by clicking on the button once but if you fill in a missing field and click the button ok then it doesnt work again ... how can i get it to work on every click ?

View 3 Replies View Related

JQuery :: Do While Loop Not Working?

May 5, 2010

I'm trying my first bit of jQuery code but am familiar with Java programming. I'm trying to create a function that loads a div with an image in it, which will fade in and then after 4 seconds move onto the next image. I want it to create an infinite loop but it doesn't work.

<script type="text/javascript">
$(document).ready(function ()
{

[code]...

View 4 Replies View Related

Nested For Loop Not Working

Oct 1, 2011

this is code for a conway's game of life. the nested loop on stepGen() doesnt work and i cant figure out what it is. no syntax errors, or anything. i put alert statements to see whats happening. i can provide the rest of the code if necessary.[code]

View 2 Replies View Related

Loop Is Not Working - Clone

Oct 11, 2011

i have this code

<script type="text/javascript">
$(document).ready(function() {
for ($i=0; $i<4; $i++) {
var num = $('.clonedInput').length;

[Code].....

the input id is changed correctly, but valores no. Why ?? Valores is always id="valores1", and must be id="valores1", id="valores2", and so on.

View 2 Replies View Related

For Loop Not Working - How To Make It Work

Jul 17, 2009

Why wont my for loop work it wont alert the var images1....

<script type="text/javascript">
for(i=1;i<6;i++){
images[i] = "no"+i+".jpg";

[code]...

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved