Calendario

Abril 2016
LunMarMierJueVierSabDom
 << <Dic 2017> >>
    123
45678910
11121314151617
18192021222324
252627282930 

Anuncio

¿Quién está en línea?

Miembro: 0
Visitante: 1

rss Sindicación

Anuncio de los artículos posteados en: Abril 2016

19 Avr 2016 

FAQ My site was hacked « WordPress Codex

Languages: English Portugus do Brasil () (Add your language)

Help I think I've been hacked

So you've carefully installed WordPress, you've made it look exactly how you like with a decent theme, you've maybe installed some fancy plugins and you've crafted some fine posts and Pages. In short, you've put a lot of time and effort into your site.



Then, one day, you load up your site in your browser, and find that it's not there, or it redirects to a porn site, or your site is full of adverts for performance-enhancing drugs. It leaves you wondering, Why would anyone hack my website? What are you supposed to do now?

The entire experience of being compromised can feel devastating, making you wonder why you ever decided to create an online presence. Rest assured though it is not the end of the world, and there a number of practical steps you can take to address the problem once it's happened, and / or prevent it from ever happening again.

Below we'll share a number of insights built over the years that will help you think through the post-hack process (i.e., what to do once a hack has occurred).

Some steps to take Stay calm. When addressing a security issue, as a website owner, you're likely experiencing an undue amount of stress. It's often the most vulnerable you have found yourself since being on line and it's contrary to what every one told you, "Hey, WordPress is Easy!!" The good news is that all is not lost! Yes, you might lose some money. Yes, you might take a hit against your brand. Yes, you will recover from this. So, yes, take a step back and compose yourself. Doing so will allow you to more effectively take control of the situation and allow you to recover your online presence. Scan your local environment. The first place you should start with is your local environment. In many cases, the source of the attack / infection begins in your local box (i.e., notebook, desktop, etc...). Make sure you run a full anti-virus/malware scan on your local machine. Some viruses are good at detecting AV software and hiding from them. So maybe try a different one. This advice extends to both Windows, OS X and Linux machines. Can't Log Into Your WordPress Admin Panel This happens more often than you might think. It's not a reason to panic. To get this going you can follow some very good steps here Reset Your Password You can leverage tools like phpMyAdmin and Adminer to log into your database directly, bypassing your WP-ADMIN and resetting your user in the users table. If you don't want to mess with password hashes or can't figure it out, simply update your email and go back to wp-admin, click forgot password, and wait for the email. Scan your website. There are various ways to do this. Today there are a number of great plugins in the repo that make this process easier. You also want to unhide all the files and folders, to include extensions for all files files. You can run a search for *.exe files, sort them by size, most malicious code is executable and is lesser than 5MB usually but can be > 5MB. Also not every .exe under 5MB is malicious, delete the known viruses/worms/autoruns, make a list of all suspected executables, check against online database. Caution: Make sure you don't delete the system files. Securelist has an article on how to find an infected file. You want to be mindful of the various types of symptoms and how they affect your website and it's visitors. For instance, malicious redirects can often be found in files like .htaccess, and index.php at the root of your website. While others will focus on the wp-content/themes directory targeting index.php, header.php, footer.php and functions.php. These are the more simple variations ofcourse. Be Mindful of Website Blacklists. Google Blacklist issues can be detrimental to your brand. They currently blacklist somewhere in the neighborhood of 9,500 to 10,000 websites a day. This number grows daily. There are various forms of warnings, from large splash pages warning users to stay away, to more subtle warnings that pop up in your Search Engine Result Pages (SERPs). Although Google is one of the more prominent ones, there are a variety of other blacklist entities like Bing, Yahoo and a wide range of Desktop AntiVirus applications. Understand that your clients / website visitors may leverage any number of tools and any one of them could be causing the issue. At a very minimum, you want to take some time to create an account with Google Webmaster tools and If you're currently infected you're going to want to look at a number of things and when you're done you'll want to follow Google's steps for reconsideration. Check with your hosting provider. The hack may have affected more than just your site, especially if you are using shared hosting. It is worth checking with your hosting provider in case they are taking steps or need to. Your hosting provider might also be able to confirm if a hack is an actual hack or a loss of service, for example. One very serious implication of a hack these days is around Email blacklisting. This seems to be happening more and more. As websites are abused to send out SPAM emails, Email Blacklist authorities are flagging the website IP's and those IP's are often associated with the same server being used for email. The best thing you can do is look at Email providers like Google Apps when it comes to your business needs. Improve your Access Controls. You will often hear folks talking about updating things like Passwords. Yes, this is a very important piece, but it's one small piece in a much larger problem. We need improve our overall posture when it comes to access control. This means using Complex, Long and Unique passwords for starters. The best recommendation is to use a Password Generator like those found in apps like 1Password and LastPass. Remember that this includes changing all access points. When we say access points we mean things like FTP / SFTP, WP-ADMIN, CPANEL (or any other administrator panel you use with your host) and MYSQL. This also extends beyond your user, and must include all users that have access to the environment. Change your secret keys. If they stole your password and are logged in to your blog, even if you change your password, they will remain logged in. How? because their cookies are still valid. To disable them, you have to create a new set of secret keys. Visit the WordPress key generator to obtain a new random set of keys, then overwrite the values in your wp-config.php file with the new ones. Take a backup of what you have left. If your files and database are still there, consider backing them up so that you can investigate them later at leisure, or restore to them if your cleaning attempt fails. Be sure to label them as the hacked site backup, though... Find and remove the hack. This is perhaps the hardest part of this entire list and the part that will require the most work. It will come down to your individual technical knowledge and insight around website hacks. To get you started though below are a few resources that will get you going in the right direction: Donncha wrote a good article on what to do if you suspect a hack, it is well worth reading through and acting on, as it goes into more depth than this page. You can also read How to clean your hacked install Sucuri has put out a number of technical posts that will help - Removing malware from a WordPress blog - which explain in details some steps you might need to take. Additionally you can leverage that post that shows you some tricks of the trade to help you get to the bottom of the issue - FTP Tips and Tricks to Help you Clean Your Website. One obvious response to a hack is to delete everything and start from scratch. Tempting, yes, but highly unrealistic. What you can do however is reinstall certain elements of the site with little regard to impacting the core of your website. You always want to make sure you reinstall the same version of software your website is using, if you choose an older or newer one you're likely to kill your website. When reinstalling, be sure not to use the reinstall options in your WP-ADMIN. Use your FTP / SFTP application to drag and drop the versions. This will prove much more effective in the long run as those installers often only overwrite existing files, and hacks often introduce new files..:) Hackers can use your .htaccess to redirect to malicious sites from your URL. Look in the base folder for your site, not just your blog's folder. Hackers will try to hide their code at the bottom of the file, so scroll down. They may also change the permissions of the .htaccess file to stop newbies from editing the file. Change the permissions back to 644. Leverage the Community We often forget but we're a community based platform, this means that if you're in trouble someone in the community is likely to give a lending hand. A very good place to start if you're strapped for cash or just looking for a helping hand is the WordPress.org Hacked or Malware forum. Another very good resource is StopBadware's Badwware Busters forum. This is a nonprofit that is committed to helping website owners just like you. Using version control? If you are using version control, it can be very handy to quickly identify what has changed and to rollback to a previous version of the website. From the terminal or command line you can compare your files with the versions stored in the official WordPress repository.

$ svn diff .

Or compare a specific file:$ svn diff /path/to/filename

Consider restoring a backup If you restore from a known clean backup of your WordPress Database, and re-upload your backed up WordPress plugin and theme files through FTP or SFTP, that will ensure that all those bits are clean of malicious code are gone. At the very least ... What? No backup? You have two very grim choices. You can start a new fresh site from scratch. You can attempt to manually locate and remove the malicious code. Even the chances of an expert being able to completely clean your site are poor. Someone can spend days looking through files, removing small snippets of hacker code. If they miss one bit, the entire hack can be replaced by the hacker in a second once the site goes online. Read about backdoors to get an idea of what you're up against. If you're reading this and have not yet been hacked and have not backed up your site, go do it NOW! Replace the core WordPress files with ones from a freshly downloaded zip. Replacing all your core files will ensure that they are no longer left in a hacked state. If you didn't already restore backup copies of your plugin and theme files, replace them too. You might also want some tips on how to think through the process of creating a good backup strategy. There are a number of steps to take into consideration, so be sure top lan accordingly. Update! Once you are clean, you should update your WordPress installation to the latest software. Older versions are more prone to hacks than newer versions. Change the passwords again! Remember, you need to change the passwords for your site after making sure your site is clean. So if you only changed them when you discovered the hack, change them again now. Again remembering to use Complex, Long and Unique passwords. Secure your site. Now that you have successfully recovered your site, secure it by implementing some (if not all) of the recommended security measures. Learn more about where WordPress is most vulnerable. Moving forward you'll want to better Understand how Websites Get Hacked and use that knowledge to better configure your environment to reduce the risk of future compromises. Forensics - Identify what happened... Once your site is secured, check your site logs to see if you can discover how the hack took place. Open source tools like OSSEC can analyze your logs and point to where/how the attack happened. Here is a nice little write up that walks you through the process of using OSSEC for your Website Security. Here is another great example of how logs can be leveraged to understand what the attacker was up to. There are also a number of other examples including this one in which a user was able to outline the various steps they took to identify how an attack happened. Keep regular backups. Now that the nightmare is over, start keeping regular backups of your database and files. If this ever happens again, all you will need to do is restore from the last known clean backup and change your passwords and secret keys.Other Resources

Back to FAQ

Admin · 18670 vistas · Escribir un comentario
19 Avr 2016 

Online Game Cheats, Bots, Hacks and Tutorials

find

welcome to hackerbot

HackerBot.net is an independent Game Hacking Site providing Reliable Information, Quality Software and Tutorials to educate people trying to learn how to cheat in games. Our Community is dedicated to discussing and sharing Cheating Methods for Online and Offline Games on PC, Consoles, Mobile and any other gaming platform.Trusted by 200.000+ Registered Users.

game cheats

tutorials



pc game cheats

software

Admin · 9822 vistas · Escribir un comentario
19 Avr 2016 

Is Wall Street too big to cheat? – Anderson Cooper 360

Ed Rollins

CNN Senior Political Contributor

Rollins: GOP should join with Democrats in passing curbs <a href=free game cheat on Wall Street's excesses" border="0" width="300" height="169"/>

Rollins: GOP should join with Democrats in passing curbs on Wall Street's excesses

As the Tea Party movement has become the vehicle for the frustration of hundreds of thousands of Americans against elected officials and the government bailout of Wall Street, I've thought many times about Gordon Gekko, the fictional character in the superb 1987 movie "Wall Street."

Played by Michael Douglas, Gekko speaks to a meeting of stockholders in words that became the anthem of the '80s. "The point is, ladies and gentleman, that greed - for lack of a better word - is good. Greed is right. Greed works!"



Keep Reading...

Admin · 28 vistas · Escribir un comentario
19 Avr 2016 

Build Your First Game With HTML5



HTML5 is growing up faster than anyone could have imagined. Powerful and professional solutions are already being developed...even in the gaming world! Check out the hundreds ofHTML5 games on Envato Market.

Today, you'll make your first game using Box2D and HTML5's canvas tag.

What is Box2D?

Box2D is an open source and popular engine that simulates 2D physics for making games and applications. Primarily written in C++, it has been converted to numerous languages by community contributors.



With the same methods and objects, you have the ability to make your games' physics in many languages, such as Objective C (iPhone/iPad), Actionscript 3.0 (Web), HTML 5 (Web), etc.

Step 1 - Setting up your Project

To begin developing your demo, download the Box2D engine for HTML5 here. Next, create a new HTML file with the following structure (copy js and lib directories from box2d-js project to your game folder).

Now, you must insert the necessary files to run box2D into your HTML file:

<!--[if IE]><script src="lib/excanvas.js"></script><![endif]--> <script src="lib/prototype-1.6.0.2.js"></script> <!-- box2djs --> <script src='js/box2d/common/b2Settings.js'></script> <script src='js/box2d/common/math/b2Vec2.js'></script> <script src='js/box2d/common/math/b2Mat22.js'></script> <script src='js/box2d/common/math/b2Math.js'></script> <script src='js/box2d/collision/b2AABB.js'></script> <script src='js/box2d/collision/b2Bound.js'></script> <script src='js/box2d/collision/b2BoundValues.js'></script> <script src='js/box2d/collision/b2Pair.js'></script> <script src='js/box2d/collision/b2PairCallback.js'></script> <script src='js/box2d/collision/b2BufferedPair.js'></script> <script src='js/box2d/collision/b2PairManager.js'></script> <script src='js/box2d/collision/b2BroadPhase.js'></script> <script src='js/box2d/collision/b2Collision.js'></script> <script src='js/box2d/collision/Features.js'></script> <script src='js/box2d/collision/b2ContactID.js'></script> <script src='js/box2d/collision/b2ContactPoint.js'></script> <script src='js/box2d/collision/b2Distance.js'></script> <script src='js/box2d/collision/b2Manifold.js'></script> <script src='js/box2d/collision/b2OBB.js'></script> <script src='js/box2d/collision/b2Proxy.js'></script> <script src='js/box2d/collision/ClipVertex.js'></script> <script src='js/box2d/collision/shapes/b2Shape.js'></script> <script src='js/box2d/collision/shapes/b2ShapeDef.js'></script> <script src='js/box2d/collision/shapes/b2BoxDef.js'></script> <script src='js/box2d/collision/shapes/b2CircleDef.js'></script> <script src='js/box2d/collision/shapes/b2CircleShape.js'></script> <script src='js/box2d/collision/shapes/b2MassData.js'></script> <script src='js/box2d/collision/shapes/b2PolyDef.js'></script> <script src='js/box2d/collision/shapes/b2PolyShape.js'></script> <script src='js/box2d/dynamics/b2Body.js'></script> <script src='js/box2d/dynamics/b2BodyDef.js'></script> <script src='js/box2d/dynamics/b2CollisionFilter.js'></script> <script src='js/box2d/dynamics/b2Island.js'></script> <script src='js/box2d/dynamics/b2TimeStep.js'></script> <script src='js/box2d/dynamics/contacts/b2ContactNode.js'></script> <script src='js/box2d/dynamics/contacts/b2Contact.js'></script> <script src='js/box2d/dynamics/contacts/b2ContactConstraint.js'></script> <script src='js/box2d/dynamics/contacts/b2ContactConstraintPoint.js'></script> <script src='js/box2d/dynamics/contacts/b2ContactRegister.js'></script> <script src='js/box2d/dynamics/contacts/b2ContactSolver.js'></script> <script src='js/box2d/dynamics/contacts/b2CircleContact.js'></script> <script src='js/box2d/dynamics/contacts/b2Conservative.js'></script> <script src='js/box2d/dynamics/contacts/b2NullContact.js'></script> <script src='js/box2d/dynamics/contacts/b2PolyAndCircleContact.js'></script> <script src='js/box2d/dynamics/contacts/b2PolyContact.js'></script> <script src='js/box2d/dynamics/b2ContactManager.js'></script> <script src='js/box2d/dynamics/b2World.js'></script> <script src='js/box2d/dynamics/b2WorldListener.js'></script> <script src='js/box2d/dynamics/joints/b2JointNode.js'></script> <script src='js/box2d/dynamics/joints/b2Joint.js'></script> <script src='js/box2d/dynamics/joints/b2JointDef.js'></script> <script src='js/box2d/dynamics/joints/b2DistanceJoint.js'></script> <script src='js/box2d/dynamics/joints/b2DistanceJointDef.js'></script> <script src='js/box2d/dynamics/joints/b2Jacobian.js'></script> <script src='js/box2d/dynamics/joints/b2GearJoint.js'></script> <script src='js/box2d/dynamics/joints/b2GearJointDef.js'></script> <script src='js/box2d/dynamics/joints/b2MouseJoint.js'></script> <script src='js/box2d/dynamics/joints/b2MouseJointDef.js'></script> <script src='js/box2d/dynamics/joints/b2PrismaticJoint.js'></script> <script src='js/box2d/dynamics/joints/b2PrismaticJointDef.js'></script> <script src='js/box2d/dynamics/joints/b2PulleyJoint.js'></script> <script src='js/box2d/dynamics/joints/b2PulleyJointDef.js'></script> <script src='js/box2d/dynamics/joints/b2RevoluteJoint.js'></script> <script src='js/box2d/dynamics/joints/b2RevoluteJointDef.js'></script>

Yep, that's a huge number of HTTP requests!

Please note that, for deployment, it's highly recommended that you concatenate all of these resources into one script file.



Next, create two more scripts inside the /js/ folder, called "box2dutils.js" and "game.js".

box2dutils.js - it's a copy and paste from some demos that come with box2dlib, and is important for drawing functions (I will also explain some important parts here). game.js - the game, itself; this is where we create the platforms, the player, apply the keyboard interactions, etc.

Copy and paste the following code into box2dutils.js. Don't worry! I'll explain it bit by bit!

function drawWorld(world, context) for (var j = world.m_jointList; j; j = j.m_next) drawJoint(j, context); for (var b = world.m_bodyList; b; b = b.m_next) for (var s = b.GetShapeList(); s != null; s = s.GetNext()) drawShape(s, context); function drawJoint(joint, context) var b1 = joint.m_body1; var b2 = joint.m_body2; var x1 = b1.m_position; var x2 = b2.m_position; var p1 = joint.GetAnchor1(); var p2 = joint.GetAnchor2(); context.strokeStyle = '#00eeee'; context.beginPath(); switch (joint.m_type) case b2Joint.e_distanceJoint: context.moveTo(p1.x, p1.y); context.lineTo(p2.x, p2.y); break; case b2Joint.e_pulleyJoint: // TODO break; default: if (b1 == world.m_groundBody) context.moveTo(p1.x, p1.y); context.lineTo(x2.x, x2.y); else if (b2 == world.m_groundBody) context.moveTo(p1.x, p1.y); context.lineTo(x1.x, x1.y); else context.moveTo(x1.x, x1.y); context.lineTo(p1.x, p1.y); context.lineTo(x2.x, x2.y); context.lineTo(p2.x, p2.y); break; context.stroke(); function drawShape(shape, context) context.strokeStyle = '#000000'; context.beginPath(); switch (shape.m_type) case b2Shape.e_circleShape: var circle = shape; var pos = circle.m_position; var r = circle.m_radius; var segments = 16.0; var theta = 0.0; var dtheta = 2.0 * Math.PI / segments; // draw circle context.moveTo(pos.x + r, pos.y); for (var i = 0; i < segments; i++) var d = new b2Vec2(r * Math.cos(theta), r * Math.sin(theta)); var v = b2Math.AddVV(pos, d); context.lineTo(v.x, v.y); theta += dtheta; context.lineTo(pos.x + r, pos.y); // draw radius context.moveTo(pos.x, pos.y); var ax = circle.m_R.col1; var pos2 = new b2Vec2(pos.x + r * ax.x, pos.y + r * ax.y); context.lineTo(pos2.x, pos2.y); break; case b2Shape.e_polyShape: var poly = shape; var tV = b2Math.AddVV(poly.m_position, b2Math.b2MulMV(poly.m_R, poly.m_vertices[0])); context.moveTo(tV.x, tV.y); for (var i = 0; i < poly.m_vertexCount; i++) var v = b2Math.AddVV(poly.m_position, b2Math.b2MulMV(poly.m_R, poly.m_vertices[i])); context.lineTo(v.x, v.y); context.lineTo(tV.x, tV.y); break; context.stroke(); function createWorld() var worldAABB = new b2AABB(); worldAABB.minVertex.Set(-1000, -1000); worldAABB.maxVertex.Set(1000, 1000); var gravity = new b2Vec2(0, 300); var doSleep = true; var world = new b2World(worldAABB, gravity, doSleep); return world; function createGround(world) var groundSd = new b2BoxDef(); groundSd.extents.Set(1000, 50); groundSd.restitution = 0.2; var groundBd = new b2BodyDef(); groundBd.AddShape(groundSd); groundBd.position.Set(-500, 340); return world.CreateBody(groundBd) function createBall(world, x, y) var ballSd = new b2CircleDef(); ballSd.density = 1.0; ballSd.radius = 20; ballSd.restitution = 1.0; ballSd.friction = 0; var ballBd = new b2BodyDef(); ballBd.AddShape(ballSd); ballBd.position.Set(x,y); return world.CreateBody(ballBd); function createBox(world, x, y, width, height, fixed, userData) if (typeof(fixed) == 'undefined') fixed = true; var boxSd = new b2BoxDef(); if (!fixed) boxSd.density = 1.0; boxSd.userData = userData; boxSd.extents.Set(width, height); var boxBd = new b2BodyDef(); boxBd.AddShape(boxSd); boxBd.position.Set(x,y); return world.CreateBody(boxBd) Step 2 - Developing the Game

Open the index.html file that you previously created, and add a canvas element (600x400) within the body element. This is where we'll work with the HTML5 drawing API:

<canvas id="game" width='600' height='400'></canvas>

Also, while you're here, reference game.js and box2dutils.js.

<script src='js/box2dutils.js'></script> <script src='js/game.js'></script>

That'll do it for the HTML! Let's work on the fun JavaScript now!

Open game.js, and insert the code below:

// some variables that we gonna use in this demo var initId = 0; var player = function() this.object = null; this.canJump = false; ; var world; var ctx; var canvasWidth; var canvasHeight; var keys = []; // HTML5 onLoad event Event.observe(window, 'load', function() world = createWorld(); // box2DWorld ctx = $('game').getContext('2d'); // 2 var canvasElm = $('game'); canvasWidth = parseInt(canvasElm.width); canvasHeight = parseInt(canvasElm.height); initGame(); // 3 step(); // 4 // 5 window.addEventListener('keydown',handleKeyDown,true); window.addEventListener('keyup',handleKeyUp,true); );Box2DWorld - that's why we're here

Okay, let's figure out what this chunk of code does!

Box2DWorld is one of the classes that is made available, via the core of box2d. Its function is simple: combine everything into one class. In box2DWorld, you have the bodies definition and collisions manager of your game or application.

Keep the game.js and box2dutils.js files open, and search for the createWorld() function within box2dutils.js.

function createWorld() // here we create our world settings for collisions var worldAABB = new b2AABB(); worldAABB.minVertex.Set(-1000, -1000); worldAABB.maxVertex.Set(1000, 1000); // set gravity vector var gravity = new b2Vec2(0, 300); var doSleep = true; // init our world and return its value var world = new b2World(worldAABB, gravity, doSleep); return world;

It's quite simple to create the box2DWorld.

Back to game.js

Refer to the commented numbers in the two blocks of code above. On number two, we retrieve the canvas element's context by using the selector API (looks like jQuery or MooTools selectors, don't they?). On number three, we have a new interesting function: initGame(). This is where we create the scenery.

Copy and paste the code below into game.js, and then we'll review it together.

function initGame() // create 2 big platforms createBox(world, 3, 230, 60, 180, true, 'ground'); createBox(world, 560, 360, 50, 50, true, 'ground'); // create small platforms for (var i = 0; i < 5; i++) createBox(world, 150+(80*i), 360, 5, 40+(i*15), true, 'ground'); // create player ball var ballSd = new b2CircleDef(); ballSd.density = 0.1; ballSd.radius = 12; ballSd.restitution = 0.5; ballSd.friction = 1; ballSd.userData = 'player'; var ballBd = new b2BodyDef(); ballBd.linearDamping = .03; ballBd.allowSleep = false; ballBd.AddShape(ballSd); ballBd.position.Set(20,0); player.object = world.CreateBody(ballBd); <p> Inside <code>box2dutils.js</code>, we've created a function, called <code>createBox</code>. This creates a static rectangle body. </p> function createBox(world, x, y, width, height, fixed, userData) if (typeof(fixed) == 'undefined') fixed = true; //1 var boxSd = new b2BoxDef(); if (!fixed) boxSd.density = 1.0; //2 boxSd.userData = userData; //3 boxSd.extents.Set(width, height); //4 var boxBd = new b2BodyDef(); boxBd.AddShape(boxSd); //5 boxBd.position.Set(x,y); //6 return world.CreateBody(boxBd) Box2DBody

A Box2DBody has some unique characteristics:

It can be static (not affected by collisions impacts), kinematic (it isn't affected by collisions, but it can be moved by your mouse, for example), or dynamic (interacts with everything) Must have a shape definition, and should indicate how the object appears May have more than one fixture, which indicates how the object will interact with collisions Its position is set by the center of your object, not the left top edge as many other engines do. Reviewing the code:Here, we create one shape definition that will be a square or rectangle, and setup its density (how often it gonna be moved, or rotate by forces). We setup the userData, usually you setup graphics objects here, but in this example, I just setup strings that will be the identifier of the type of the object for collisions. This parameter doesn't affect physics algorithms. Setup half of the size of my box (it's a line from the position point, or the center point of the object to a corner) We create the body definition, and add to it the box shape definition. Setup the position. Create the body in the world and return its value. Creating the Player Ball Body

I've coded the player (ball) directly in the game.js file. It follows the same sequence of creating boxes, but, this time, it's a ball.

var ballSd = new b2CircleDef(); ballSd.density = 0.1; ballSd.radius = 12; ballSd.restitution = 0.5; ballSd.friction = 1; ballSd.userData = 'player'; var ballBd = new b2BodyDef(); ballBd.linearDamping = .03; ballBd.allowSleep = false; ballBd.AddShape(ballSd); ballBd.position.Set(20,0); player.object = world.CreateBody(ballBd);

So how do we create a body, step by step?

Create the shape, fixture and sensor definition Create the body definition Add into the body your shape, fixtures or sensors (not explained in this article) Create the body in the world Box2DCircle

As I noted earlier, this follows the same creation process of a box, but now you must set some new parameters.

radius - This is the length of a line from the center of the circle to any point on its edge. restitution - How the ball will lose, or gain force when collides with other body. friction - How the ball will roll. Box2DBody - More Propertiesdamping is used to reduce the velocity of the body - there's angular damping and linear damping. sleep in box2D, bodies can sleep to solve performance issues. For example, let's suppose you are developing a platform game, and the level is defined by a 6000x400 screen. Why do you need to perform physics for objects that are off screen? You don't; that's the point! So the correct choice is to put them to sleep, and improve your game's performance.

We've already created our world; you can test the code that you have so far. You'll see the player falling above the west platform.

Now, if you tried to run the demo, you should be wondering, why is the page as barren as white paper?



Always remember: Box2D doesn't render; it only calculates physics.

Step 3 - Rendering Time

Next, let's render the box2DWorld.



Open your game.js script, and add the following code:

function step() var stepping = false; var timeStep = 1.0/60; var iteration = 1; // 1 world.Step(timeStep, iteration); // 2 ctx.clearRect(0, 0, canvasWidth, canvasHeight); drawWorld(world, ctx); // 3 setTimeout('step()', 10); What we accomplish here:Instructed box2dWorld to perform physics simulations Cleared canvas screen and draw again Execute the step() function again in ten milliseconds

With this bit of code, we are now working with physics and drawing. You can test yourself, and watch for a falling ball, as demonstrated below:

drawWorld in box2dutils.jsfunction drawWorld(world, context) for (var j = world.m_jointList; j; j = j.m_next) drawJoint(j, context); for (var b = world.m_bodyList; b; b = b.m_next) for (var s = b.GetShapeList(); s != null; s = s.GetNext()) drawShape(s, context);

What we've written above is a debug function that draws our world into the canvas, using the graphics API provided by HTML5's Canvas API.

The first loop draws all joints. We didn't use joints in this article. They are a bit complex for a first demo, but, nonetheless, they're essential for your games. They allow you to create very interesting bodies.

The second loop draws all bodies, which is why we're here!

function drawShape(shape, context) context.strokeStyle = '#000000'; context.beginPath(); switch (shape.m_type) case b2Shape.e_circleShape: var circle = shape; var pos = circle.m_position; var r = circle.m_radius; var segments = 16.0; var theta = 0.0; var dtheta = 2.0 * Math.PI / segments; // draw circle context.moveTo(pos.x + r, pos.y); for (var i = 0; i < segments; i++) var d = new b2Vec2(r * Math.cos(theta), r * Math.sin(theta)); var v = b2Math.AddVV(pos, d); context.lineTo(v.x, v.y); theta += dtheta; context.lineTo(pos.x + r, pos.y); // draw radius context.moveTo(pos.x, pos.y); var ax = circle.m_R.col1; var pos2 = new b2Vec2(pos.x + r * ax.x, pos.y + r * ax.y); context.lineTo(pos2.x, pos2.y); break; case b2Shape.e_polyShape: var poly = shape; var tV = b2Math.AddVV(poly.m_position, b2Math.b2MulMV(poly.m_R, poly.m_vertices[0])); context.moveTo(tV.x, tV.y); for (var i = 0; i < poly.m_vertexCount; i++) var v = b2Math.AddVV(poly.m_position, b2Math.b2MulMV(poly.m_R, poly.m_vertices[i])); context.lineTo(v.x, v.y); context.lineTo(tV.x, tV.y); break; context.stroke();

We're looping through every vertices of the object and drawing it with lines (context.moveTo and context.lineTo). Now, it's useful to have an example... but not so useful in practice. When you use graphics, you only need to pay attention to the bodies' positioning. You don't need to loop vertices, as this demo does.

Step 4 - Interactivity

A game without interactivity is a movie, and a movie with interactivity is a game.



Let's develop the keyboard arrow functionality to jump and move the ball.

Add the following code to your game.js file:

function handleKeyDown(evt) keys[evt.keyCode] = true; function handleKeyUp(evt) keys[evt.keyCode] = false; // disable vertical scrolling from arrows :) document.onkeydown=function()return event.keyCode!=38 && event.keyCode!=40

With handleKeyDown and handleKeyUp, we setup an array which tracks every key the user types. With document.onkeydown, we disable the browser's native vertical scrolling function for up and down arrows. Have you ever played an HTML5 game, and when you jump, the player, enemies and objects go off screen? That won't be an issue now.

Add this next bit of code to the beginning of your step() function:

handleInteractions();

And outside, declare the function:

function handleInteractions() // up arrow // 1 var collision = world.m_contactList; player.canJump = false; if (collision != null) collision.GetShape2().GetUserData() == 'player') collision.GetShape2().GetUserData() == 'ground')) var playerObj = (collision.GetShape1().GetUserData() == 'player' ? collision.GetShape1().GetPosition() : collision.GetShape2().GetPosition()); var groundObj = (collision.GetShape1().GetUserData() == 'ground' ? collision.GetShape1().GetPosition() : collision.GetShape2().GetPosition()); if (playerObj.y < groundObj.y) player.canJump = true; // 2 var vel = player.object.GetLinearVelocity(); // 3 if (keys[38] && player.canJump) vel.y = -150; // 4 // left/right arrows if (keys[37]) vel.x = -60; else if (keys[39]) vel.x = 60; // 5 player.object.SetLinearVelocity(vel);

The most complicated piece of the code above is the first one, where we check for a collision, and write some conditions to determine if the shape1 or the shape2 is the player. If it is, we verify if shape1 or shape2 is a ground object. Again, if so, the player is colliding with the ground. Next, we check if the player is above the ground. If that's the case, then the player can jump.

On the second commented line (2), we retrieve the LinearVelocity of the player.

The third and forth commented regions verify if arrows are being pressed, and adjust the velocity vector, accordingly.

In the fifth region, we setup the player with the new velocity vector.

The interactions are now done! But there's no objective, We just jump, jump, jump and jump!

Step 5 - "You Win" Message

Add the code below to the beginning of your LinearVelocity function:

if (player.object.GetCenterPosition().y > canvasHeight) player.object.SetCenterPosition(new b2Vec2(20,0),0) else if (player.object.GetCenterPosition().x > canvasWidth-50) showWin(); return; The first condition determines if the player falls, and should be transported back to the start point (above the west platform). The second condition checks if the player is above the second platform, and won the game. Here's the showWin() function. function showWin() ctx.fillStyle = '#000'; ctx.font = '30px verdana'; ctx.textBaseline = 'top'; ctx.fillText('Ye! you made it!', 30, 0); ctx.fillText('thank you, andersonferminiano.com', 30, 30); ctx.fillText('@andferminiano', 30, 60);

And that's it! You've just completed your first simple game with HTML5 and Box2D. Congratulations!

If you need a simpler solution, you could check out the selection of HTML5 games on Envato Market, many of which come with source code for you to investigate and customize to fit your own needs.

Admin · 15824 vistas · Escribir un comentario
19 Avr 2016 

HackYourConsole.com shut down after Nintendo lawsuit

As reported earlier this month, Nintendo filed a lawsuit against website HackYourConsole.com with claims that The site blatantly promotes and sells unauthorized Nintendo games along with devices and services that circumvent the security in the Nintendo DS system and the Wii console.

While no formal statement has been free download issued, it looks like Nintendos legal action did its job because as of August 26th, just 19 days later, HackYourConsole.com is out of service with the only remaining message, The site is out of service. At this time all Pre-orders have been cancelled. No new orders will be accepted.

In addition to shutting down their web business, HackYourConsole.com has also taken down their Facebook page and Twitter feed.

Nintendo has been after HackYourConsole.com for a while now due to their sale of R4 and other flashcarts that allow users to play pirated games on official Nintendo DS systems. Since Nintendo doesnt own a patent on flash memory technology, they couldnt stop either the manufacture or sales of the carts.

When HackYourConsole.com recently started taking pre-orders for the upcoming Gateway 3DS, a cart that could be used for playing pirated Nintendo 3DS games, Nintendo had enough and unleashed their lawyers.

HackYourConsole.com stated on FAQ section of their website that The cards themselves aren't illegal because there's plenty of things that are legitimately free for them. It's the actual ds games that you download that are illegal. However, they set up the flashcarts with the latest hack of Nintendos firmware to make it that much easier to access and play pirated games.

It is still unclear if the site is out of business because HackYouConsole.com lost the lawsuit, settled out of court, or just gave up because they couldnt afford the legal fees to go up against the video game industry giant.

Now that HackYourConsole.com is no more, there is no official distributor of R4, flashcarts and the Gateway 3DS within the United States, but as history has proven, the hackers will still find a way.

You can read the original story about the lawsuit here.



Admin · 26 vistas · Escribir un comentario

Página precedente  1, 2, 3, 4, 5, 6, 7, 8, 9  Página siguiente