1 Replies - 1044 Views - Last Post: 19 December 2012 - 08:00 AM

#1 LukeAnderton  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-December 12

How to get multiple bouncing balls not using a canvas ?

Posted 19 December 2012 - 07:14 AM

I am trying to get multiple bouncing(flying) balls moving around inside a background area.

The problem i have is that my tutors says i can not use the preferred method of canvas or jquery. as i am new to javascript can anybody help me out with any solutions to this problem please ?

i dont have any code to provide for this.


cheers.
Is This A Good Question/Topic? 0
  • +

Replies To: How to get multiple bouncing balls not using a canvas ?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3710
  • View blog
  • Posts: 5,958
  • Joined: 08-June 10

Re: How to get multiple bouncing balls not using a canvas ?

Posted 19 December 2012 - 08:00 AM

Well, you could just create <img> elements with ball images, set up a timer to execute a function every 1000/60 milliseconds (~16.667), and inside that function update the positions of those balls using the standard Javascript style properties.

Here are some references to get you started:

document.getElementById()
Gets an element on the page by it's "id" attribute. Use this to grab a reference to your image elements to be used in your Javascript code.

element.style
This is how you manipulate the CSS styles of elements in Javascript code.

About Element Positioning
An explanation of the various ways in which elements can be positioned using CSS. Pay special attention to Absolute and Relative positioning.

window.setInterval
This allows you to execute code repeatedly every X milliseconds.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1