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


ADVERTISEMENT

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 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

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

Os Detection

Jul 23, 2005

I have a page with a script that works only in IE and as I heard from
feedbacks it doesn't run under IE on Mac.

I have browser type redirect script for that page that seems to be
working fine except it doesn't detect the OS ( IE on Mac just gives
blank page). Can someone add to the code that I would give me one page
for IE on Windows and another one for all others? Code:

View 1 Replies View Related

Self Detection

Jul 20, 2005

I have on different form elements an onChange routine.

Now I was wondering how I can see which element fired the routine. Can I
write something like "if (self.name=='elementA')"?

View 1 Replies View Related

Pop-Up Closure Detection

Nov 21, 2009

I'm using the code below for the "launch page" to open a JS window and know when it has been closed, and than execute some other code that should be run after the pop-up closes.

javascript Code:

This works, and does exactly what I want. Do any of you JS experts see any reason for concern? Anything that makes it suboptimal?

View 3 Replies View Related

Browser Detection

Jan 30, 2007

So I need script, which will detect users browser, and if browser will be IE, then show some link in content, if browser is FireFox or Opera, then hide that link. Link looks like:

<tr>
<td align='center' valign='top'><a href='/' target='_blank'>link</a></td>
</tr>

View 4 Replies View Related

IP Detection Script

Sep 28, 2005

I would like to have my page display the IP address of the user when the page loads. I have heard of the IP detection scripts when using the
"var ip = '<!--#echo var="REMOTE_ADDR"-->" attribute to make a window or alert popup and display the IP of the user, and I have also come some scripts that display the IP in the status bar. However, I want the current IP adress to be shown on the page itself, part of the <Body>.

View 2 Replies View Related

Object Detection

Mar 23, 2006

function doDOMStuff() {
var el = document.getElementById('myElId');
// object detection
if(!document.getElementById) return false;

//or

if(!document.getElementById) return;

// doStuff
}

View 5 Replies View Related

Cookie Detection

Jan 18, 2004

I currently have a site which uses cookies, the problem is that I want it to detect if the browser being used has cookies enabled. I know you can accomplish this by setting a cookie in JavaScript and testing for it (i don't know how to do it, though), *BUT* I need the script to be compliant with all (or at least most) browsers. By this I mean, Mozilla, Firebird, Opera, IE, Netscape, and anything else you can think of.

View 2 Replies View Related

Object Detection For IE 6 Only

Oct 3, 2004

Is there a simple object detection to sniff for IE 6 only ( not IE 5.5 or lower ) ?

View 2 Replies View Related

Plugin Detection For IE 5.5?

Apr 23, 2001

How do you find out if a certain Plugin has been installed in IE 5.5 using Javascript?

I know that in netscape you can use navigator.plugins so I was hoping there was something as easy as this.

View 2 Replies View Related

Javascript Browser Detection

Jul 23, 2005

I have some html code i would like to be printed to the page only if the
browser has javascript enabled. I have tried to use document.writeln()
but the string i want to print bot contains some ' and " in it. I don't
know how to set the delimiters of the string that is passed as argument
so that i don't get an error in the page.

View 1 Replies View Related

Browser Version Detection: How?

Jul 23, 2005

I've have got this script, the only thing I want to be changed is the first part. It has to detect IE version 6 instead of just "Microsoft Internet Explorer". Can somebody help me out? I tried "Microsoft Internet Explorer 6" but that doesn't work.

<SCRIPT LANGUAGE="Javascript">
<!--
bName = navigator.appName;
if (bName =="Microsoft Internet Explorer") {
document.write('<link media="screen" rel="STYLESHEET" type="text/css"
href="stylesheet1.css">')
} else {
document.write('<link media="screen" rel="STYLESHEET" type="text/css"
href="stylesheet2.css">')
}
//-->
</SCRIPT>

View 8 Replies View Related

Window Scroll Detection

Jul 23, 2005

How to detect that user started to scroll the page ? Separately vertical and
horizontal scroll. Is it possible ?

View 2 Replies View Related

Popup Blocker Detection

Jul 23, 2005

We have a database application that runs in a popup Internet Explorer
application window. The reason for this is to isolate the casual user
from the address bar and the typical IE navigation buttons.

The application has a browser test page that displays an error message
when a popup blocker is found and opens a popup page stating the test
was successfull if there is no popup blocker.

Is there a reliable method (preferably javascript) for detecting the
major popup blockers (SP2, AOL, Yahoo, Google, MSN, etc.)? We currently
have a temporary solution in place which works OK but we would like to
have a better solution.

We have already reasearched this on the net, as well as spent a few
hours trying different options.

The application is designed to run on MSIE only so the solution can be
Explorer specific.

View 26 Replies View Related

Shift Key Detection On Input

Mar 23, 2006

I'd like to detect the shift key when a button is "clicked" in
Firefox/Mozilla. If the button is clicked with the mouse, no problem.
However, if the onclick event is keyboard originated, then my method is
not working. Same thing for SELECT elements.

The simple web page below shows the issue. Click with the mouse while
holding down the shift key, and the Shift key's status registers.
However, use Shift+Alt+o, or either (while the button has focus)
Shift+Space or Shift+Enter to kick off the onClick event and the shift
key is not detected. Works fine with IE 6 on my Win XP Pro. Code:

View 7 Replies View Related

Browser Detection Code

Jul 20, 2005

I want to know the height of the viewable portion of a page (minus scrollbar)
in Opera and Mozilla.

For Opera, I could use document.body.clientHeight. Unfortunately, this won't
work in Mozilla because Mozilla also subtracts the sizes of the top and bottom
margins.

For Mozilla, I could use document.documentElement.clientHeight.
Unfortunately, this won't work in Opera because Opera returns the height of
the entire page, not just the viewable portion.

So I have two options:

1) Use browser detection code to determine if the user is running Opera or
Mozilla, and then use the appropriate clientHeight code.

2) Use window.innerHeight. This is supported by both Opera and Mozilla,
however it returns the height of the viewable portion of the page *including*
the scrollbar. Is there any way to determine the width of a scrollbar? If
not, then I would have to make an assumption and subtract the hardcoded width
of the scrollbar from window.innerHeight... but only if the scrollbar is
present, is there a way to determine that?

View 4 Replies View Related

Browser Size Detection

Jan 7, 2006

Well after playing around a little I have created a solution that works although it appears a little chunky. The problem was finding the browser size to use the width as a variable for size conditional aspects to a site. Code:

View 8 Replies View Related

Browser Detection Script (+)

Jan 28, 2006

I am looking for a detailed and correct browser detection script. Preferable a one that does not detect based on the UA string, but detects using DOM model or tests for functions, etc...

I'd like it to return OS, Browser and version as a separate variables.

View 14 Replies View Related

Simple Browser Detection

Jan 31, 2006

What is the most ACCURATE but LIGHTWEIGHT and SIMPLE way of determining whether a user has Microsoft Internet Explorer?

View 1 Replies View Related

Monitor Resolution Detection

Jul 22, 2006

I am developing a website in which I will support two screen resolutions ( 800X600 & 1024X768 ) by using two different stylesheets for better browsing experience. I need a code to detect resolution and then putting the desired stylesheet in page code at request time. If there is any server side language to be used with it then I can use PHP.

View 11 Replies View Related

Frame Detection Script

Jul 23, 2002

I need a script that detects if the browser is viewing a certain page within a frameset, and if it is not, to open the page through frameset instead.

For example if the site has a mainframe and a navframe, if someone goes to the mainframe from a search engine, the script will open up the frameset html so the navframe shows up too.

View 4 Replies View Related







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