Jakarta – Founder and Chief Executive Officer of Google, Larry Page, said he likes to wear Google Glass although not as often as his fellow founders, Sergey Brin ie.

“It was like living in the future,” he said when presenting the company’s performance for the second quarter via teleconference. “It really makes me excited.” At a wedding in Croatia, Larry is seen wearing smart glasses.

“For some people, working on crazy projects are very challenging,” he continued. “Attempting to change the world with ten co-workers.”

Some projects that turned into a popular product used by many people in the world like Gmail, Chrome, and Android. “I see the results of our work on a number of projects and I feel satisfied.”

Several other projects are being worked on is the smart glasses Glass, Google Now, Project Loon, and a vehicle without a driver. “Misrepresentation if we assume the technology will be static,” he said.

CATEGORIES : Computer Technology, Hardware/ AUTHOR : besteckverleih/ 0 Comment


NEW YORK (TheStreet) — Facebook’s (FB_) second-quarter earnings focused on mobile revenue. Shares were soaring in premarket trading Thursday as Wall Street raised price targets and upgraded shares.

 The Menlo Park, Calif.-based social networker earned 19 cents a share on $1.813 billion in revenue for the quarter, as mobile advertising revenue accounted for 41% of advertising revenue this quarter. Total advertising revenue was $1.6 billion, 88% of total revenue, and up 61% year over year.

Analysts surveyed by Thomson Reuters were expecting Facebook to earn 14 cents a share on $1.62 billion in revenue for the quarter.

The company ended the quarter with 1.15 billion monthly active users (MAUs), up 21% year over year. There was a 51% annual increase in mobile MAUs, which drove the strength in mobile revenue. Daily active users (DAUs) were 699 million, up 27% annually.

Following the earnings, many analysts were bullish, with several upgrading shares and raising price targets. Here’s what some analysts on Wall Street had to say:

JPMorgan analyst Doug Anmuth (Overweight, $44 PT)

“Facebook delivered its strongest quarter yet as a public company–results that we think could be thesis-changing for many–and we would continue to buy Facebook shares even after the ~17% move up in the after-market. Our revenue and nonGAAP EPS estimates increase 12% and 38% for 2013, and 22% and 46% for 2014.”

Topeka Capital Markets analyst Victor Anthony (Buy, $40 PT)

“Facebook needed to, and delivered, a blowout quarter. What is clear from the results is advertisers have validated Facebook as an advertising platform. For full year 2013, our revenue and Adj. EPS increases to $7.196B and $0.71, resp, from $6.733B and $0.63. We still see more upside for the stock and recommend purchase. There are several well defined catalysts over the next two years that should lead to further share price appreciation, including: 1) monetizing Instagram, which, per CEO Zuckerberg, will generate “a lot of profits”, 2) launch of auto-play video ads, 3) monetizing Graph Search, 4) a bigger push into e-commerce, and 5) the potential for S&P 500 inclusion. Further, only 1mm or 6% of FB’s 18mm potential advertisers are buying ads, implying a huge runway for advertiser uptake exists.”

Sterne Agee analyst Arvind Bhatia (Buy, $37 PT)

“We are incrementally bullish on FB’s prospects following 2Q results and believe the stock should be a core holding in Internet portfolios. 2Q’s highlight was Mobile advertising (+76% q/q versus consensus +20%). Overall revenue (53% y/y) and EBITDA (+57% y/y) accelerated from 1Q’s 38%/35% revenue/EBITDA growth. Better than expected user engagement, strong monetization and good cost control helped FB outperform even the most bullish expectations on the Street. Reiterating Buy.”

Oppenheimer analyst Jason Helfstein (Outperform, $36 PT)

“Following materially better than expected 2Q results, we are increasing our estimates and price target, and are reiterating our Outperform rating. 2Q upside was driven by higher advertiser demand for newsfeed, both on volume and price, and since mobile Newsfeed pricing is similar to desktop and advertisers are largely indifferent between mobile and desktop, revenues are tracking the consumer shift to smartphones. We believe this dynamic is an important differentiator vs. other ad-supported internet companies, that are being hurt by the mobile mix shift. As such, we are increasing ’13E and ’14E revenue by 3% and 5%, and non-GAAP EPS by 7% and 9%, respectively. Raising target to $36 from $32.”

Shares of Facebook were soaring following earnings, tacking on 30.48% to $34.59 in premarket trading.

CATEGORIES : Computer Technology, Internet Informations/ AUTHOR : besteckverleih/ 0 Comment


Ghiboo.com – HTC finally officially introduced its latest smartphone which is a mini series of HTC.

Quoted from Techradar, Friday (19/7), it is clearly seen that the presence of HTC Mini is to become a major competitor Samsung Galaxy S4 Mini.

With frills ‘Mini’, of course, HTC offers a size and a smaller screen than the original version. In addition, some hardware also decreased.

HTC Mini armed with a 4.3-inch 720p display with overall body dimensions are 132×63, 2×9, 25mm and weighing 122gram. The processor used is a dual-core 1.4GHz with 1GB RAM and support for 16GB of internal memory.

Ultrapixel camera still be the main dish, which fortunately, had equivalent quality original HTC. The Taiwanese manufacturers rely on the operating system of Android 4.2.2 Jelly Bean, plus the HTC Sense UI and Blinkfeed are also provided.

There is no information about when the HTC One Mini will be released to the market, as well as about the price. To be sure, if you really want to compete directly with the Galaxy S4 Mini, of course, the price offered will not differ much.

CATEGORIES : Computer Technology, Hardware/ AUTHOR : besteckverleih/ 0 Comment


Panasonic not only introduced the new Lumix cameras that rely on high zoom capability. The Japanese company also helped bring a compact camera Lumix DMC-XS3 that rely 14.1 MP MOS sensor with high sensitivity.

This digital camera is designed with a slim shape and body size of 14 millimeters. Although the size is quite small, this camera is claimed to deliver high quality images thanks to sensors that can reduce noise. In addition, this camera also features a 5x optical zoom and 10x zoom intelegent.

Panasonic Lumix DMC-XS3 also has the ability to record full HD video in MP4 format. In it there is also a feature called Intelligent Auto (iA) which enables features like Intelligent ISO Control, Intelligent Scene Selector, Face Detection and Intelligent Exposure is done automatically.

For shooting in low-light atmosphere, there is a Handheld Night Shot mode. This mode can produce high quality images with a single shot.

CATEGORIES : Computer Technology, Hardware/ AUTHOR : besteckverleih/ 0 Comment


Jakarta (Reuters) – In the midst of the Muslims fasting Ramadan, Indonesian BlackBerry app launches pay the Zakat charity through the foundation for users of smart phones or smart phones.
“This may be an application of zakat (charity) is the first in the world in the BB World. Users can perform three types of payments that zakat religious endowments, Infaq, and Sadaqah,” said Managing Director BB Maspiyono Handoyo Indonesia in Jakarta, Friday night.
Applications can be downloaded on zakat homes BlackBerry World for free to all BB “Operating System” (OS), including 10 BB. The application is made by software developers (software) Indonesia PT Jaya Dihital Solutions, said Maspiyono accompanied by Head of Distribution Management and Ibn Rumah Zakat Cholidin infallible, software developers Alms Houses in BB.
Cholidin said, Rumah Zakat application will allow users to calculate the monthly zakat and provide complete information on activities, projects, and news from the zakat.
Features at Zakat House includes an easy interface to support user transactions, zakat calculator helps the user to determine the amount of funds that will be donated, the latest news about the activities of the Zakat House, related to the purchase of livestock Superqurban needs of Eid al-Adha, and Infaq Card support users make a donation for 100 years until after the death, clearly Cholidin.
But for the payment, users still have to do the transfer via ATM Bank. But in the future, will be developed through a transaction online payment system or by use BB Money, adds Ibn infallible, the developer of the software.
“With this app in BB, we would like to pay zakat into a lifestyle that gives peace and pleasure of living in the world. Such people using BB or other gadgets. Pay zakat is made easy,” said Cholidin.
Meanwhile Managing Director BB Maspiyono added, with this application, users not only get the benefits of BB ease in running businesses and organizations, but also the ease of paying zakat and “ticket” to heaven.
According Cholidin, existing donors who pay zakat through BB worth Rp172 billion from Rp400 million earned in a year Alms Houses.

CATEGORIES : Computer Technology, Software/ AUTHOR : besteckverleih/ 0 Comment


One of the local players present Tabulet one variant tablet at an affordable price. Tabulet Tabz Voice offers its flagship feature supports high definition multimedia content and also provides GSM slot that can be used to make phone calls and SMS. By using a battery capacity of 3000mAh, the device is claimed to last longer: 7 to 8 days in standby mode.

u2-436-TabuletDengan adds Voice name, this device is indeed favor the communication features via phone and SMS. All are able to run smoothly without any obstacles, it’s just a network that supports only a 2.75 G which is less convenient if you want to use it for internet connection. The solution, Voice Tabz support the use of USB modem via USB OTG cable.

Using unibodi design, no casing that must be removed. You just insert your SIM card if you want to use it for communication via phone / SMS. However, this function does not support hot swap. If you directly install the SIM card without turning off the tablet, the SIM card is not immediately detectable. You can do the first restart to activate it.

Tabulet Tabz Voice has front and rear cameras, and you can use the front camera for video calls. However, this function can be done using third party applications such as Skype. Rear camera with 2 megapixel resolution to produce images that are optimal in conditions outside the brightly lit room, in addition to the results look less blurry and the colors are natural. You can also use it to record video with VGA resolution.

To run high-definition video, which has included supporting applications Super HD-Player. Video codec and format support diverse, ranging from RM / RMVB, AVI, MKV, MOV, DAT, FLV, H.264 to be directly executed here. So if you have a video file and move it to this tablet, can be directly executed without the need to convert it first. Output sound through the internal speakers produce a sound that is quite loud, but it just is mono only. If you want to produce stereo sound, can use headphones.

The default application is fairly small but has included three exciting games are Angry Birds, Fruit Ninja, and Temple Run. To support your activities, of course stay put himself through Google Play.

One interesting alternative to the tablet at an affordable price offered by Tabz Tabulet Voice. His ability to make phone calls and SMS as well as running high definition video to excellence that is rarely found in the price range of millions.

CATEGORIES : Computer Technology, Hardware/ AUTHOR : besteckverleih/ 0 Comment


While using hashtags in Facebook posts might be a fun tactic for brands trying to engage consumers, it doesn’t appear to be paying off, a new study finds.
Research from social media analytics firm Simply Measured revealed that while 20 percent of Facebook posts among top brands now include hashtags (which give users a way to group messages of similar content), there is no evidence that hashtags are influencing engagement.

The study shows that posts with hashtags —a new feature added with in the last several months — perform as well as those without, suggesting that people are not yet discovering brand posts by their tags.

Overall, the study shows nearly all of the companies in the Interbrand 100 — which ranks businesses based on financial status — now have a Facebook fan page, with 60 percent posting something at least once a day.

[No, Really, Facebook Makes Employees More Productive]

The research revealed that visual content is by far the primary driver for engagement on Facebook. Photos posted by top brands average more than 9,400 engagements, which includes likes, comments and shares, per post, while video posts average more than 2,500.

When it comes to text posts, brands must walk a fine line. Analysis of more than 500 status updates from the top brands shows that the longer a status update is, the less engagement it typically receives. However, if a status update is too short — less than 50 characters — it may not be long enough to capture viewers’ attention or provide the necessary context to drive the number of likes, shares and comments a brand would like.

“For most brands, Facebook is no longer just a network; it has become the hub of their social marketing efforts and one of the most effective ways to engage with fans,” said Adam Schoenfeld, CEO of Simply Measured. “This latest research once again proves that knowing your audience, understanding your content assets and measuring your efforts are extremely important to develop the social strategies that will work best for you.”

Businesses that limit Facebook fans from writing on their page might want to reconsider their strategy. The research shows that nearly 30 percent of top brands do not allow users to post on their wall. For those brands, user engagement on their page is limited to likes, comments and shares, resulting in 15 percent less engagement than brands that do allow user posts.

When it comes to drawing the most Facebook fans, no one does it better than Facebook itself. The social media giant claims the top spot with 93 million fans, followed by Coca-Cola and MTV.

CATEGORIES : Computer Technology, Internet Informations/ AUTHOR : besteckverleih/ 0 Comment


Dock is part desktop OS X that characterizes Apple’s flagship computer operating system. Dock functions such as running apilkasi shortcuts or files and move from one application to another. To move from window to another window in an application, the user must use the OS X Exposé. But, what if asiknya application icon in the Dock to have features such as Windows 7, which the user can select a window which opens directly without having to rely on Exposé.

For those of you who want those features, can wear DockView apps in the App Store.

Like I mentioned earlier, DockView able to provide thumbnail windows of an application by placing the cursor over the application that has many windows.

DockView also supports thumbnail windows through the App Swithcer. Suitable for you who frequently use the App Swithcer to move the window. Still clumsy with App Swithcer? Just look at the previous tips, about maximizing the use of the App Swithcer.

Label the price is free, but it actually has a Dock View in app purchase to eliminate loading thumbnail window sometimes appears for a few seconds.

Additional Dock DockView a supplement that must be considered to accelerate access to switch between windows.

CATEGORIES : Computer Technology, Software/ AUTHOR : besteckverleih/ 0 Comment


Global desktop PC sales continue to slow. However, this does not preclude Hewlett-Packard (HP) to continue releasing the latest desktop PC product lines.

No half-hearted, at an event in Jakarta, Wednesday (07/24/2013), HP released 4 series desktop PCs at once, namely EliteOne 800 G1, G1 EliteDesk 800, ProOne 600 G1, and G1 ProDesk 600. The four were aimed at the business segment.

Present as a business device, HP equip these devices with a variety of features that do not exist in the PC consumer.

For example, four of which are equipped with a safety feature called HP Client Security. Using these features, users can protect the devices at every layer, including hardware, software, and BIOS.

Other value, the products have passed the test of military standards. According to Ricky Handrian, MDM Business Desktop PC HP Indonesia, standardization include durability, shock, and temperature.

These devices have to endure or withstand heavy overwritten with a maximum weight of 75 kg. In addition, products with military standards must withstand shock, although it has been taken away in a car in the distance.

“Devices that pass this certification should still be able to operate, though it was taken in a truck and suffered shock, for example, 1,000 miles,” said Ricky.

HP Series 800 G1 EliteOne a version All-in-one PC from EliteDesk 800 G1. This product is available in one version a touch screen and non-touch also.

Those who are interested can choose the specifications of the product. To EliteOne 800 G1, specification available is generation Intel Core processors up to 4 Haswell, Windows 8 Pro, up to 16 GB of RAM, up to 1 TB HDD, and a 23-inch LED screen.

Meanwhile, the desktop version of this device, EliteDesk 800 G1, comes with a slightly higher specification, namely 4-generation Intel Core processor Haswell, Windows 8 Pro, 32 GB RAM, and up to 2 TB HDD.

Carrying the same concept with the EliteBook 800, ProOne 600 HP version of the G1 is the all-in-one PC from HP ProDesk 600 G1. For the problem specification, these two products have the same choice as the Elite 800 series.

So, what distinguishes the two series? According to Ricky, the two series have different processor platforms support. 800 Series uses Intel Q87 platform. While the Pro 600 series using Q85.

“ProDesk Series 600 is a downgraded version of the EliteBook 800. ProDesk device 600 is certainly cheaper than EliteBook 800. Yeah, let’s just ProDesk 600 as the sister of the EliteBook 800,” added Ricky.

CATEGORIES : Computer Technology, Hardware/ AUTHOR : besteckverleih/ 0 Comment


Prerequisites

  • A browser with WebGL – this game has been tested on Chrome and Firefox. IE still doesn’t support WebGL, unless you’re using Windows 8.1 with IE11.
  • Three.js library available for download from the Three.js website
  • The Keyboard.js helper library I used for this project, created by Arthur Schreiber at No Karma. Download it from my GitHub repository
  • A basic understanding of what Three.js does. Read this super simple, super quick tutorial by Paul Lewis. It’s basically a short-hand version of this article.

Setup

Get a base index.html running

Step one when making a web-based game is to create the host index.html file. In our case, it only needs to be a very simple set of elements, so we can bundle the CSS styling too.

Import Keyboard.js and Three.js

Three.js is a library contained in just one JavaScript file, so we can grab the minified version from the website.

For Keyboard input, we will need to referencethe aforementioned JavaScript file in our index.html as well.

Create setup() and draw() functions

The setup() function will be the start point for the game code. The draw() function will be run every frame and will handle all the rendering and game logic.

In order to loop the draw() function, we simply utilise the requestAnimationFrame() function call, and pass ‘draw’ as the parameter. Remember, not all browsers natively support the call, and you might have to use Paul Irish’s shim to gain maximum compatibility. Also, it is important to realise that requestAnimationFrame() does not guarantee a fixed frame-rate, so you need to use time-deltas to calculate realistic physics. For a basic game like Pong, we don’t really care about that.

Basic World

Set up the Three.js world and camera

Three.js includes these important elements:

  • Scene
  • Renderer
  • Camera
  • Mesh
  • Light
  • Material

Cameras, Meshes, and Lights need to be added to the scene using the scene.add() function.

Attach a WebGL Three.js Renderer to the DIV

The renderer is attached to whichever HTML DOM element you wish to render the scene to, and a render() call is made each frame to the renderer in order to draw the Three.js scene.

Add a camera to the scene

Three.js has the option to create Perspective and Orthographic cameras. For most uses, Perspective camera is the best choice. We can change position and rotation information of the camera like any other object in the scene.

Draw a sphere and light it

Meshes must be paired with Materials in order to give them a defined look and feel. Meshes can be of many types, include primitives such as Cube, Sphere, Plane and Torus. Materials can have different characteristics depending on their type. The basic Material types include Lambert, Phong, and Basic.

  • Basic renders an unlit Mesh with no shadows or dark shading. A sphere will look like a circle if rendered with Basic.
  • Lambert is a simple diffuse-like lighting that creates shading on sides facing away from a light source. It gives a basic 3D look of surfaces that are matte (non-shiny and non-reflective)
  • Phong is used for achieving a plastic-like look and feel, with the ability to gain highlights that give a much shinier appearance to the Mesh.

Show off your sphere with a Point Light. This is the most basic light, with no direction or rotation. Make sure you tweak the light’s intensity and distance to get it looking good.

Add Game Objects

Draw playing area plane

The playing area will be a Three.js Mesh object of type Plane. Make sure the plane matches the play area, giving a small buffer gap to indicate where the paddles can and can’t go.

Draw paddles

The paddles will be Mesh objects of type Cube. Position each of the paddles on opposite sides of the play area.

1234567891011121314151617181920212223242526272829303132333435363738394041
// set up the paddle vars
paddleWidth = 10;
paddleHeight = 30;
paddleDepth = 10;
paddleQuality = 1;
// set up paddle 1
paddle1 = new THREE.Mesh(
new THREE.CubeGeometry(
paddleWidth,
paddleHeight,
paddleDepth,
paddleQuality,
paddleQuality,
paddleQuality),
paddle1Material);
// add the paddle to the scene
scene.add(paddle1);
// Set up the second paddle
paddle2 = new THREE.Mesh(
new THREE.CubeGeometry(
paddleWidth,
paddleHeight,
paddleDepth,
paddleQuality,
paddleQuality,
paddleQuality),
paddle2Material);
// Add the second paddle to the scene
scene.add(paddle2);
// set paddles on each side of the table
paddle1.position.x = -fieldWidth/2 + paddleWidth;
paddle2.position.x = fieldWidth/2 – paddleWidth;
// lift paddles over playing surface
paddle1.position.z = paddleDepth;
paddle2.position.z = paddleDepth;
view rawBNG_Pong_paddlecreateThis Gist brought to you by GitHub.

If you manipulate the camera positions, as seen in the screenshot, you can give a different perspective to the player.

Basic Logic

Ball movement

The ball will have an X-direction and a Y-direction that determines the movement per frame.

// ball’s x-direction, y-direction and speed per frame
var ballDirX = 1, ballDirY = 1, ballSpeed = 2;

The ball will move at a constant speed in the X-plane every frame. To this end, we will specify a ballSpeed variable that acts as a multiplier for the direction values.

// update ball position over time
ball.position.x += ballDirX * ballSpeed;
ball.position.y += ballDirY * ballSpeed;

We want the ball to have some unpredictable characteristics (e.g. when it gets sliced quite hard) so we will allow the Y-direction to go up to a maximum of ballSpeed * 2. You can tweak the values until you’re happy with how the ball behaves.

// limit ball’s y-speed to 2x the x-speed
// this is so the ball doesn’t speed from left to right super fast
// keeps game playable for humans
if (ballDirY > ballSpeed * 2)
{
ballDirY = ballSpeed * 2;
}
else if (ballDirY < -ballSpeed * 2)
{
ballDirY = -ballSpeed * 2;
}

Ball wall bounce logic

Simple collision detection logic is required to check if the ball is touching each of the side ‘walls’. Using a series of ‘if-else’ statements, we check the ball positions against the predetermined wall positions. In the case of a collision, we simply switch the Y-direction of the ball, creating a bounce effect.

// if ball goes off the top side (side of table)
if (ball.position.y <= -fieldHeight/2)
{
ballDirY = -ballDirY;
}
// if ball goes off the bottom side (side of table)
if (ball.position.y >= fieldHeight/2)
{
ballDirY = -ballDirY;
}

Later, we will edit some of this code in order to implement scoring when the ball passes a paddle.

Keyboard input for paddles

We will utilise a very effective short-cut in order to easily get keyboard input working in this game. Using the Keyboard.js file provided, we simply have to include the reference to it in the index.html file and we are set. Only one function call is required, the Key.isDown() call. Given a parameter, the library checks if that particular key is current being pressed, and returns a boolean value.

// move left
if (Key.isDown(Key.A))
{
// code to move paddle left
}

We use the ‘A’ and ‘D’ keys to move the paddle left and right, but you can edit the Keyboard.js with additional values if you want to use your own control scheme.

var Key = {
_pressed: {},
A: 65,
W: 87,
D: 68,
S: 83,
// add your required key code (ASCII) along with the name here
// for example:
SPACE: 32,
};

While dealing with keyboard input, it is also important to ensure that the input is never blindly updated in game. We have to check that the paddle isn’t made to move off the play area, and we do that with some ‘if-else’ statements as well.

// move left
if (Key.isDown(Key.A))
{
// if paddle is not touching the side of table
// we move
if (paddle1.position.y < fieldHeight * 0.45)
{
paddle1DirY = paddleSpeed * 0.5;
}
// else we don’t move and stretch the paddle
// to indicate we can’t move
else
{
paddle1DirY = 0;
paddle1.scale.z += (10 – paddle1.scale.z) * 0.2;
}
}

Note that we use a paddle direction variable, rather than simply applying a change to the position values. This will come in handy when programming the ball to ‘slice’ when hit at an angle with a fast-moving paddle.

Opponent logic

When you code a game of this calibre, it is of utmost importance that you create a vivid, lush environment with a host of emotional, highly-relatable characters that showcase this generation’s strides forward in technology. Instead, we will code a Pong A.I. that blindly follows the ball, because that is even better.

We can update the opponent difficulty by using a variable instead of introducing magic numbers. This variable will affect the ‘reaction rate’ of the opponent by increasing the Lerp (Linear-Interpolation) time.

When using a Lerp (Linear-Interpolation) function, we must ensure the opponent plays fairly by limiting their maximum travel speed. We do that with a few more if-else statements.

// in case the Lerp function produces a value above max paddle speed, we clamp it
if (Math.abs(paddle2DirY) <= paddleSpeed)
{
paddle2.position.y += paddle2DirY;
}
// if the lerp value is too high, we have to limit speed to paddleSpeed
else
{
// if paddle is lerping in +ve direction
if (paddle2DirY > paddleSpeed)
{
paddle2.position.y += paddleSpeed;
}
// if paddle is lerping in -ve direction
else if (paddle2DirY < -paddleSpeed)
{
paddle2.position.y -= paddleSpeed;
}
}
If want to extend immersion, you could also using the paddle.scale property to stretch the paddle when it can’t be moved. This indicates an issue to the player which they can then address immediately. In order to accomplish this, we must ensure the paddle always Lerps back to the default scale size.
// We lerp the scale back to 1
// this is done because we stretch the paddle at some points
// stretching is done when paddle touches side of table and when paddle hits ball
// by doing this here, we ensure paddle always comes back to default size
paddle2.scale.y += (1 – paddle2.scale.y) * 0.2;

Adding Gameplay

Making the ball reset after missing a paddle

To get the main scoring gameplay working, we need to first remove the ball’s ability to bonce off the paddle-facing walls. To do this, we remove the bounce code from the two corresponding if-else statements.

// if ball goes off the top side (side of table)
if (ball.position.y <= -fieldHeight/2)
{
ballDirY = -ballDirY;
}
// if ball goes off the bottom side (side of table)
if (ball.position.y >= fieldHeight/2)
{
ballDirY = -ballDirY;
}
//// ——————————— ////
CHANGED CODE
//// ——————————— ////
// if ball goes off the ‘left’ side (Player’s side)
if (ball.position.x <= -fieldWidth/2)
{
// CPU scores a point
// update scoreboard
// and reset ball
}
// if ball goes off the ‘right’ side (CPU’s side)
if (ball.position.x >= fieldWidth/2)
{
// player scores a point
// update scoreboard
// and reset ball
}

We can handle scoring in many different ways. For a simple game like this, we can simply increment the corresponding score count variable.

// if ball goes off the ‘left’ side (Player’s side)
if (ball.position.x <= -fieldWidth/2)
{
// CPU scores
score2++;
// update scoreboard HTML
document.getElementById(“scores”).innerHTML = score1 + “-” + score2;
// reset ball to center
resetBall(2);
// check if match over (someone scored maxScore points)
matchScoreCheck();
}

We can then update the HUD element in the DOM by setting its innerHTML value. Finally, we have to reset the ball once someone has scored. A simple function can be written to reset the ball, with a parameter indicating which paddle just lost (so we know which paddle to send the ball to next time).

// resets the ball’s position to the centre of the play area
// also sets the ball direction speed towards the last point winner
function resetBall(loser)
{
// position the ball in the center of the table
ball.position.x = 0;
ball.position.y = 0;
// if player lost the last point, we send the ball to opponent
if (loser == 1)
{
ballDirX = -1;
}
// else if opponent lost, we send ball to player
else
{
ballDirX = 1;
}
// set the ball to move +ve in y plane (towards left from the camera)
ballDirY = 1;
}

Making the ball bounce off paddles

Alright, this is it. The big one. Literally the biggest feature of this game. It’s time to get the paddles hitting the ball. In a simple Pong game, paddle-ball physics are nothing more than a couple of if-else statements. We check the X-position and Y-position of the ball against the paddle’s rectangular bounds, and if they intersect, we bounce the ball away.

// if ball is aligned with paddle1 on x plane
// remember the position is the CENTER of the object
// we only check between the front and the middle of the paddle (one-way collision)
if (ball.position.x <= paddle1.position.x + paddleWidth
&& ball.position.x >= paddle1.position.x)
{
// and if ball is aligned with paddle1 on y plane
if (ball.position.y <= paddle1.position.y + paddleHeight/2
&& ball.position.y >= paddle1.position.y – paddleHeight/2)
{
// ball is intersecting with the front half of the paddle
}
}

It’s also important to check the direction of the ball’s travel, as we only want to check collisions in one direction (the direction towards the opponent.)

// and if ball is travelling towards player (-ve direction)
if (ballDirX < 0)
{
// stretch the paddle to indicate a hit
paddle1.scale.y = 15;
// switch direction of ball travel to create bounce
ballDirX = -ballDirX;
// we impact ball angle when hitting it
// this is not realistic physics, just spices up the gameplay
// allows you to ‘slice’ the ball to beat the opponent
ballDirY -= paddle1DirY * 0.7;
}

We will also affect the ball’s lateral movement depending on the relative speed of the paddle when hitting the ball. This is particularly useful in introducing the biggest variable in Pong: the slice. Slicing the ball is often the only way to confuse and outmaneuver the opponent, so it is vital in this game.

Remember to duplicate the code, but update the values to match the opponent’s paddle. You can use this opportunity to gimp your opponent’s ability somewhat, by reducing the hitbox size or decreasing the slice amount. It’s what we would all do.

Here is the final paddle-ball collision function:

// Handles paddle collision logic
function paddlePhysics()
{
// PLAYER PADDLE LOGIC
// if ball is aligned with paddle1 on x plane
// remember the position is the CENTER of the object
// we only check between the front and the middle of the paddle (one-way collision)
if (ball.position.x <= paddle1.position.x + paddleWidth
&& ball.position.x >= paddle1.position.x)
{
// and if ball is aligned with paddle1 on y plane
if (ball.position.y <= paddle1.position.y + paddleHeight/2
&& ball.position.y >= paddle1.position.y – paddleHeight/2)
{
// and if ball is travelling towards player (-ve direction)
if (ballDirX < 0)
{
// stretch the paddle to indicate a hit
paddle1.scale.y = 15;
// switch direction of ball travel to create bounce
ballDirX = -ballDirX;
// we impact ball angle when hitting it
// this is not realistic physics, just spices up the gameplay
// allows you to ‘slice’ the ball to beat the opponent
ballDirY -= paddle1DirY * 0.7;
}
}
}
// OPPONENT PADDLE LOGIC
// if ball is aligned with paddle2 on x plane
// remember the position is the CENTER of the object
// we only check between the front and the middle of the paddle (one-way collision)
if (ball.position.x <= paddle2.position.x + paddleWidth
&& ball.position.x >= paddle2.position.x)
{
// and if ball is aligned with paddle2 on y plane
if (ball.position.y <= paddle2.position.y + paddleHeight/2
&& ball.position.y >= paddle2.position.y – paddleHeight/2)
{
// and if ball is travelling towards opponent (+ve direction)
if (ballDirX > 0)
{
// stretch the paddle to indicate a hit
paddle2.scale.y = 15;
// switch direction of ball travel to create bounce
ballDirX = -ballDirX;
// we impact ball angle when hitting it
// this is not realistic physics, just spices up the gameplay
// allows you to ‘slice’ the ball to beat the opponent
ballDirY -= paddle2DirY * 0.7;
}
}
}
}
view rawBNG_Pong_paddlecollCompleteThis Gist brought to you by GitHub.

Scoring

In Pong, it is usually simplest to have a maximum score value, such that a game is won when either player reaches that score. To that end, we can easily create a maxScore variable and set it at the start of the match.

We then create a function to check if either player has scored equal or higher than the maximum. This function should be called only when a score has been changed (i.e. when someone scores a point.)

// checks if either player or opponent has reached 7 points
function matchScoreCheck()
{
// if player has 7 points
if (score1 >= maxScore)
{
// stop the ball
ballSpeed = 0;
// write to the banner
document.getElementById(“scores”).innerHTML = “Player wins!”;
document.getElementById(“winnerBoard”).innerHTML = “Refresh to play again”;
}
// else if opponent has 7 points
else if (score2 >= maxScore)
{
// stop the ball
ballSpeed = 0;
// write to the banner
document.getElementById(“scores”).innerHTML = “CPU wins!”;
document.getElementById(“winnerBoard”).innerHTML = “Refresh to play again”;
}
}

After a match is deemed complete, it is simplest to just return the ball to the centre and stop any movement, so that play doesnt inadvertently continue.

Prettifying the Game

HUD

It’s important to give feedback to the player so they know what’s going on. For Pong, the least we can do is keep a scoreboard ticking over. Instead of trying to draw the HUD on the same layer as the game, we can use the other DOM elements to provide the required feedback.

It’s also good to indicate the maximum score as well, so we have another element for that which we will update at match start.

// update the board to reflect the max score for match win
document.getElementById(“winnerBoard”).innerHTML = “First to ” + maxScore + ” wins!”;

Shadows

Finally, it is time to make things look a tad more polished. Three.js has the awesome ability to create shadows for primitive objects (Cube, Plane, Sphere, etc.) so we can utilise that to make the game look nicer.

Shadows can’t be created with just a Point light, so we have to add a DirectionalLight or a SpotLight. A SpotLight shines a circular beam of light onto surfaces, which DirectionalLight simply shines a light in a certain direction with no regard to positioning.

We will use a SpotLight because it clearly indicates where the light originates from and shines towards.

We can update the SpotLight to follow the ball around to give a more dynamic look and feel to the game, whilst showcasing the hard work we just put into the lighting.

// we can easily notice shadows if we dynamically move lights during the game
spotLight.position.x = ball.position.x;
spotLight.position.y = ball.position.y;

To make an object in the scene cast or receive shadows, we simply set their .receiveShadow and .castShadow variables to true. For example,

paddle1 = new THREE.Mesh(
new THREE.CubeGeometry(paddleWidth, paddleHeight, paddleDepth, paddleQuality, paddleQuality, paddleQuality),
paddle1Material);
// add the sphere to the scene
scene.add(paddle1);
paddle1.receiveShadow = true;
paddle1.castShadow = true;

Conclusion

This is but a basic introduction to the power of Three.js, which should allow you to create a basic Pong clone.

Play the latest build of this game here: LATEST BUILD*

Find the latest code at its GitHub page*

You can still do quite a number of things to polish your game, such as

  • Create animations for the paddles and ball
  • Update the HUD to look prettier
  • Import complex objects created in Modeling packages, to design a more immersive environment
  • Move HUD elements inside the game view to allow for full-screen gaming
  • Mess around with complex shaders to create reflections and other cool effects
CATEGORIES : Computer Technology, Programming/ AUTHOR : besteckverleih/ 0 Comment