PONG+ JAVASCRIPT

PLAY Pong Plus

 

Basic features:

  • Health Bars: Each time player fails to reflect a ball, the health bar decreases in length. If the health reaches zero, the game is over.
  • POW bars: It allows the player to use Power Ups, such as Bubble Shields and Rainbow Shots. Each use of the Power Ups consumes a certain amount of POWs.
  • Slippery Paddles: Paddles do not stop immediately if the player stops pressing UP/Down buttons. The paddles decelerate and cushion in. This feature makes the paddles harder to control and challenges players to plan the moves ahead.
  • The ball: The ball will shoot from the center with a random color, size, speed, and angle.
  • Sound: added sound effects and music (Enjoy it!).

 

 

Advanced features:

  • Bubble Shield: Players can consume POWs to generate a bubble shield. It reflects the balls back.
  • Rainbow Shot: Players can consume POWs to activate the paddles into rainbow mode. Any ball hits a paddle with rainbow mode will be reflected and move at a doubled speed.
  • Reflection: Balls will bounce back from each other.
  • Exchange of Momentum: If a rainbow ball hits a normal ball, they will exchange the momentum. Meaning the normal ball will become a rainbow ball and vice versa.
  • Particles: A particle system is built in this game. If a ball hits the left or right boundary, it will explode and generate a particle cluster, like fireworks.

 

Music License:

RoccoW_-07-_Fuck_Sidechain_Compression_on_Gameboy.mp3
ロッコ by RoccoW is licensed under a Attribution-ShareAlike License.
Based on a work athttps://roccow.bandcamp.com/album/-
Permissions beyond the scope of this license may be available atwww.soundcloud.com/roccowor contact artist via email.

Prime number algorithm

1 st method (very inefficient):

get value for an number n
if n =2, output “It is a prime number”
set the value i =2;
set the value isPrime = True;
if i if n % i == 0, isPrime=False;
else i + 1;
output “It is a prime number” if isPrime is true
output “It is a not prime number” if isPrime is False.

The above method is inefficient. If the input is a very big prime number, it will make division from 2 all the way to n-1.

2nd method (slightly faster):

If :
an integer x < another integer n,
√n % x != 0 (n is not divisible by x )
then: n² % x !=0 (n² is not divisible by x)

Vise versa, n % x == 0, then n² % x ==0 ;

So, we can implement the 1st method, by looping only from 2 to n. we just have to modify the above algorithm “i<n” into “i<√n”. it optimized (n ) algorithm into (√n) algorithm.

3rd method (Sieve of Eratosthene):
This method works when given a number n and get all the prime numbers that is smaller than n. It filters out all the composite numbers, and left the prime number.

It works in this way:

  1. given a number n,
  2. in the range of 2 to n, find the prime number one by one.
    • the first prime number is 2, then filter out all the numbers that is multiple of 2.
    • find the next prime number, which is 3, and filter out all the multiples of 3.
    • find the next prime number 5, and filter out all the multiples of 5.
    • continue the above process. until the searched prime number reaches n.
  3. output all the remaining numbers.

The pseudo code would be:

  1. given a number n, n>1
  2. define a list IsPrime[], indexed from 2 to n, initially all items are set to True
  3. i start from 2, if i < n, repeat the following steps:

if IsPrime[i] == true:

set IsPrime[ i2, i2+i, i2+2i, i2+3i, …] to False (not exceeding n)

      4.output the indices in IsPrime[] ‘s item that is true.

Run the Script in CodeSkulptor

 

Simple Automation for Maya Rendering

Maya Batch Render doesn’t allow user to render multiple shots with one click. What if I want to let the computer create a render queue and automate the rendering process? You may install backburner to solve this. or there is another simple way of doing so without setting up the Manager and Server.

First of all, create a .bat file from Windows desktop.

The Template is like this:

C:\Progra~1\Autodesk\Maya2014\bin\render -r file -s <starting_frame> -e <ending_frame> -cam <camera> -rd “<render_location>” “<maya_file_directory>”

here under are the possible settings that you can modify

-r file: render from scene setting.

-s : starting frame

-e: ending frame

-cam: camera Name

-rd: where you want to save rendered image / where is the maya file.

For more info for rendering command, refer to this link.