Monday 3 December 2018

Source code for a snake game in Java Language

A Snake game developed in Java Language for bigginners to understand how can they make simple game by thereself

Here is the code with comments for better understand




/**
 * A Bigginers start version of the classic arcade game
 * "Snake"
 - Made code more readable
 * Also Comments added to understand code propely
 */

///////////// SETTINGS /////////////

// number of {rows|columns}
var N = 20;

// starting length of snake
// click "Restart" if you change this
var START_LENGTH = 1;

// increase to slow down the game
var GAME_SPEED = 3;

// how many cycles to wait before letting the
// user restart
var GAME_OVER_TIMEOUT = 20;

// if false, game over when snake moves beyond
// game boundaries
var WRAP_AROUND = true;


///////////// GLOBAL VARIABLES /////////////

var apple; // the avatar to be eaten next
var snake;

var gameOver; // true when the game is over
var gameOverTimer;

// height is the canvas height
var rowHeight = height / N;
// keep track of arrow keypresses
var keystack = [];

///////////// IMAGE VARIABLES /////////////

var star = getImage("cute/Star");
var oldspice = getImage("avatars/old-spice-man");
var mrpink = getImage("avatars/mr-pink");
var marcimus = getImage("avatars/marcimus");
var pants = getImage("avatars/mr-pants");
var squid = getImage("avatars/orange-juice-squid");
var purple = getImage("avatars/purple-pi");
var images = [oldspice, mrpink, marcimus,
              pants, squid, purple];


///////////// UTILITY FUNCTIONS /////////////

// generate a random integer
var randomInt = function(min, max) {
    var num = random(min, max);
    return floor(num);
};

// a generic timer function
var Timer = function(limit) {
    // initialize
    var t = limit;
    return {
        reset: function() {
            t = limit;
        },
        decr: function() {
            if (t > 0) {
                t -= 1;
            } else {
                t = 0;
            }
        },
        isUp: function() {
            return t === 0;
        }
    };
};

// record key presses
var keyPressed = function() {
    if (!gameOver) {
        if (keyCode === RIGHT || keyCode === LEFT ||
            keyCode === UP || keyCode === DOWN) {
            keystack.push(keyCode);
        }
    }
};


///////////// DRAWING FUNCTIONS /////////////

var drawUnit = function(row, col, i) {
    var h = rowHeight;
    var x = col * h;
    var y = row * h;
    image(images[i], x, y, h, h);
};


var drawBackground = function(opacity) {
    fill(36, 36, 36, opacity);
    rect(0, 0, height, height);
};

var drawGrid = function() {
    stroke(46, 46, 46);
    for (var i = 0; i < N; i += 1) {
        var x = i / N * height;
        line(x, 0, x, height);
        line(0, x, height, x);
    }
};

var drawGameOverScreen = function() {
    drawBackground(150);
    var font = createFont("monospace", 20);
    textFont(font, 20);
    textSize(60);
    fill(49, 201, 26);
    text("GAME OVER", 38, 175);
    textSize(26);
    text("Score: " + snake.score(), 132, 239);
    if (gameOverTimer.isUp()) {
        textSize(16);
        text("Press any key to start over.", 66, 314);
    }
};


///////////// APPLE /////////////

var Apple = function() {

    this.init = function() {
        this.row = randomInt(0, N);
        this.col = randomInt(0, N);
        this.img = randomInt(0, images.length);
    };

    this.positionMatch = function(row, col) {
        return this.row === row && this.col === col;
    };

    this.draw = function() {
        stroke(69, 69, 69);
        strokeWeight(1);
        fill(20, 20, 20);
        var h = rowHeight;
        var x = (this.col + 0.5) * h;
        var y = (this.row + 0.5) * h;
        ellipse(x, y, h * 1.5, h * 1.5);
        drawUnit(this.row, this.col, this.img);
    };

    this.init();
};


///////////// SNAKE /////////////

var Snake = function() {
    var rowArr = []; // row index of each body part
    var colArr = []; // column index of each body part
    var imgArr = []; // index of image for each body part
    var direction; // current direction of snake movement
    var nextDirection; // direction in the next frame

    var score; // number of apples this snake has eaten

    var init = function() {
        // start with a brand new snake
        rowArr = [];
        colArr = [];
        imgArr = [];

        // start the snake off in the upper left corner
        // the last element is the head
        for (var i = 0; i < START_LENGTH; i += 1) {
            rowArr.push(0);
            colArr.push(i);
            // generate a random image for each body
            // segment
            imgArr.push(randomInt(0, images.length));
        }

        // start snake moving to the right
        direction = RIGHT;

        score = 0;
    };

    // delta (change increment) for the snake's movement
    var getDelta = function(direction) {
        var row = 0;
        var col = 0;
        if (direction === DOWN) {
            row = 1;
        } else if (direction === UP) {
            row = -1;
        } else if (direction === LEFT) {
            col = -1;
        } else if (direction === RIGHT) {
            col = 1;
        }
        return {row: row, col: col};
    };

    // set index so that it's within the bounds [0, N-1]
    var makeInBounds = function(index, wrapAround) {
        if (!wrapAround) {
            if (index === N || index === -1) {
                gameOver = true;
                return;
            }
        } else {
            if (index === N) {
                index = 0;
            } else if (index === -1) {
                index = N;
            }
        }
        return index;
    };

    // true if a snake segment exists at (row, col)
    var segmentAt = function(row, col) {
        var len = rowArr.length;
        for (var i = 0; i < len; i += 1) {
            if (row === rowArr[i] && col === colArr[i]) {
                return true;
            }
        }
        return false;
    };

    var changeDirection = function() {
        var dir = direction;
        // by default the next direction will be the
        // same as the current direction
        nextDirection = dir;

        if (keystack.length) {
            var key = keystack.pop();
            if (dir === RIGHT || dir === LEFT) {
                if (key === UP || key === DOWN) {
                    nextDirection = key;
                }
            } else if (dir === UP || dir === DOWN) {
                if (key === RIGHT || key === LEFT) {
                    nextDirection = key;
                }
            }
        }
    };

    this.move = function(apple) {
        // don't move unless the frame number is a
        // multiple of GAME_SPEED
        if (frameCount % GAME_SPEED !== 0) {
            return;
        }

        changeDirection();

        // get snake "head"
        var row = rowArr[rowArr.length-1];
        var col = colArr[colArr.length-1];

        // get next movement
        direction = nextDirection;
        var delta = getDelta(direction);
        var rowNext = row + delta.row;
        var colNext = col + delta.col;
        rowNext = makeInBounds(rowNext, WRAP_AROUND);
        colNext = makeInBounds(colNext, WRAP_AROUND);

        // if the snake collides with itself, game over
        if (segmentAt(rowNext, colNext)) {
            gameOver = true;
        }

        // exit before advancing the snake
        if (gameOver) {
            return;
        }

        // if the next movement lands on the apple
        if (apple.positionMatch(rowNext, colNext)) {
            // add it to the snake tail
            imgArr.unshift(apple.img);
            apple.init();
            score++;
        } else {
            // otherwise, "move" the snake by removing
            // the tail segment
            rowArr.shift();
            colArr.shift();
        }

        // "move" the snake by adding a new segment to
        // the head (note that imgArr is not changed)
        rowArr.push(rowNext);
        colArr.push(colNext);
    };

    this.draw = function() {
        fill(255, 64, 64);
        var h = rowHeight;
        var len = rowArr.length;
        for (var i = 0; i < len; i += 1) {
            if (i === len - 1) {
                // draw a star for the head
                var x = colArr[i] * h;
                var y = (rowArr[i] - 0.7) * h;
                image(star, x, y, h, h * 2);
            } else {
                // use the image for everything else
                drawUnit(rowArr[i], colArr[i], imgArr[i]);
            }
        }
    };

    this.score = function() {
        return score;
    };

    init();
};


///////////// START GAME /////////////

var startGame = function() {
    snake = new Snake();
    apple = new Apple();

    gameOverTimer = Timer(GAME_OVER_TIMEOUT);
    gameOver = false;
};

// begin with a new game
startGame();


///////////// MAIN GAME LOOP /////////////

var draw = function() {
    drawBackground(255);
    drawGrid();

    snake.draw();
    apple.draw();

    if (!gameOver) {
        snake.move(apple);
    } else {
        drawGameOverScreen();
        // don't let the user restart the game
        // until the timer is up
        if (keyIsPressed && gameOverTimer.isUp()) {
            startGame();
        } else {
            gameOverTimer.decr();
        }
    }
};

Monday 26 November 2018

How to Hack any Android Phone Remotely with SpyNote?

How to Hack any Android Phone Remotely with SpyNote?

How to Hack any Android Phone Remotely with SpyNote?
Smartphones have taken over the computers and laptops. They just rushed into everyone’s life in this modern age. Computers are getting replaced with these mobile devices which you can use on the go. Did you ever think to hack into someone’s smartphone to spy on messages, calls and anything you love to do remotely? Wanted to monitor your child’s smartphone activity? If yes, here I will show you how to hack any android phone remotely.
Note: This tutorial is only for educational purpose.

How to Hack any Android Phone Remotely?

Requirements:

Following are the requirements to get started.
  1. Java Installed PC
  2. SpyNote (Remote Administration Tool), download it from here.
  3. Dynamic IP (noip.com host)
  4. DUC (noip.com client)
  5. Victim

Steps to hack any android phone remotely

  1. Download and install JAVA from Oracle official website.
  2. Download SpyNote from here. You can also download other versions of SpyNote v4 or SpyNote v5.
  3. Now we need a dynamic host/IP. Simply go to noip.com and sign up. After signup click on Add Host and enter any name for your host and click Save Host.
  4. After creating host, download DUC from here.
  5. Now we need to port forward from our router’s settings. For this we need to know our gateway IP. Simply go to Command Prompt and type ipconfig. It will give your gateway IP.
  6. Open up the browser and paste your gateway IP and hit enter. It’ll prompt for username and password. You can find username and password under your router. By default it’s admin for username and password.
  7. As you give username and password, you’ll see router settings page. Navigate to Port Forwarding option. Click on Add a Port and enter port 1337 and save. Do it again for the port 2222. You can put any port you want to use.
  8. Every thing’s great till now. Let’s create an APK server for the smartphone. Extract and open the folder of SpyNote. It’ll be having an application named as SpyNote.exe. Just open it, as you open it will ask for the port to listen. Enter 2222 port here and we’re in the SpyNote GUI.
  9. Next, click on the Tools tab and click on Build button.                        SpyNote Tutorial
  10. As you hit on Build button, you’ll see a screen like below. you just need to change your host name that you just created on noip.com. Just change that and other settings you can change if you want to. And hit the Build button.       SpyNote Configuration
  11. After hitting Build button, it’ll create APK server in the output folder.
  12. Now we just need to copy the APK to the smartphone and have to install it. You can do social engineering to convince them to install the APK.
  13. As it’ll get installed, you’ll be able to see the notification of client connection to the SpyNote and it’ll appear in the main screen like the screenshot below. Hacking a Smartphone with SpyNote
  14. Congratulations..!!! You’re into the victim’s phone now. To perform any action on the smartphone, Right click on the user that just appeared in the SpyNote window.             Hack Smartphone using SpyNote
  15. Here you can see many actions that you can perform on the smartphone in the above screenshot. Just click on any action you want to execute.
That’s all..:) You have done all to hack any android phone remotely.

Monday 19 November 2018

Best IDE Software – a List of the Top 10 (With Description)



Best IDE Software – a List of the Top 10
Whether you’re a seasoned developer or you’re just learning how to code, staying on top of the latest integrated development environments is a constant challenge. Truthfully, there is no best IDE for everyone. The best IDE is the IDE that works best for you, so below is a selection of 10 of the most popular choices to help you figure out which one to pick.

How is an IDE Different From a Text Editor?

An IDE is more than a simple text editor. While code-centric text editors such as Sublime or Atom offer many convenient features such as syntax highlighting, customizable interfaces and extensive navigation tools, they only allow you to write code. To make functioning applications, you at least need a compiler and a debugger.
An IDE includes all of these components and then more. Some IDEs come with additional tools for automating, testing and visualizing the development process. The term “integrated development environment” means that you have everything you need to turn code into functioning apps and programs.
Which is the best IDE on the market? The better question is: “Which is the best IDE for my purposes?” General factors to consider when choosing the best IDE include the languages it can support, ease of use and cost.
Check out the list below outlining the features and drawbacks of each of the top 10 best IDE software programs.

1. Microsoft Visual Studio

visual studio ide banner
Microsoft Visual Studio is a premium IDE ranging in price from$699 - $2,900 depending on the edition and licensing. The many editions of this IDE are capable of creating all types of programs ranging from web applications to mobile apps to video games. This series of software includes tons of tools for compatibility testing so that you can see how your apps run on more than 300 devices and browsers. Thanks to its flexibility, Visual Studio is a great tool for both students and professionals.
Languages Supported: ASP.NET, DHTML, JavaScript, JScript, Visual Basic, Visual C#, Visual C++, Visual F#, XAML and more
Notable Features:
  • A massive library of extensions that is always growing
  • IntelliSense
  • Customizable dashboard and dockable windows
  • Straightforward workflow and file hierarchy
  • Insights for monitoring performance in real time
  • Automation tools
  • Easy refactoring and code snippet insertion
  • Split screen support
  • Error list that allows debugging while building
  • Approval checks when deploying apps via ClickOnce, Windows Installer or Publish Wizard
Drawbacks: Because the Visual Studio is a heavyweight IDE, it takes considerable resources to open and run, so making simple edits may be time consuming on some devices. For simpler task, it may be easier to use a lightweight editor.

2. NetBeans

netbeans ide banner
Netbeans is a free and open-source IDE. Ideal for editing existing projects or starting from scratch, NetBeans boasts a simple drag-and-drop interface that comes with a myriad of convenient project templates. It is primarily used to develop Java applications, but you can download bundles that support other languages.
Languages Supported: C, C++, C++11, Fortan, HTML 5, Java, PHP and more
Notable Features:
  • Intuitive drag-and-drop interface
  • Dynamic and static libraries
  • Multi-session GNU debugger integration with code assistance
  • Allows for remote development
  • Compatible with Windows, Linux, OS X, and Solaris platforms
  • Supports Qt Toolkit
  • Supports Fortan and Assembler files
  • Supports a number of compilers including CLang/LLVM, Cygwin, GNU, MinGW and Oracle Solaris Studio
Drawbacks: This free IDE consumes a lot of memory, so it may perform sluggishly on some machines.

3. PyCharm

pycharm ide banner
PyCharm is developed by the folks over at Jet Brains and provides users a free Community Edition, 30-day free trial for the Professional Edition, $213 - $690 for an annual subscription. Comprehensive code assistance and analysis make PyCharm the best IDE for Python programmers of all ability levels. PyCharm also supports other languages and works on multiple platforms, so practically anyone can use it.
Languages Supported: AngularJS, Coffee Script, CSS, Cython, HTML, JavaScript, Node.js, Python, TypeScript and template languages
Notable Features:
  • Compatible with Windows, Linux, and Mac OS
  • Comes with Django IDE
  • Easy to integrate with Git, Mercurial and SVN
  • Customizable interface with VIM emulation
  • JavaScript, Python and Django debuggers
  • Supports Google App Engine
Drawbacks: Users complain that PyCharm has some bugs, such as the autocomplete feature occasionally not working, which can be a minor inconvenience.

4. IntelliJ IDEA

intellij ide banner
IntelliJ IDEA is another IDE developed by Jet Brains. This IDE offers users a free Community Edition, 30-day free trial for the Ultimate Edition, and costs $533 - $693 annually depending on features. IntelliJ IDEA, which supports Java 8 and Java EE 7, comes with extensive tools to develop mobile apps and enterprise technologies for different platforms. When it comes to cost, IntelliJ is a real deal due to the massive of list of features you get.
Languages Supported: AngularJS, CoffeeScript, CS, HTML, JavaScript, LESS, Node JS, PHP, Python, Ruby, Sass, TypeScript and more.
Notable Features:
  • Extensive database editor and UML designer
  • Supports multiple build systems
  • Test runner UI
  • Code coverage
  • Git integration
  • Supports Google App Engine, Grails, GWT, Hibernate, Java EE, OSGi, Play, Spring, Struts and more
  • Deployment and debugging tools for most application servers
  • Intelligent text editors for HTML, CSS, and Java
  • Integrated version control
  • AIR Mobile supports Android and iOS devices
Drawbacks: This IDE comes with a learning curve, so it may not the best for beginners. There are many shortcuts to remember, and some users complain about the clunky UI.

5. Eclipse

eclipse ide banner
Eclipse is a free and flexible open source editor useful for beginners and pros alike. Originally a Java environment, Eclipse now has a wide range of capabilities thanks to a large number of plug-ins and extensions. In addition to debugging tools and Git/CVS support, the standard edition of Eclipse comes with Java and Plugin Development Tooling. If that’s not enough for you, there’s plenty of other packages to choose from that include tools for charting, modeling, reporting, testing and building GUIs. The Eclipse Marketplace Client gives users access to a treasure trove of plugins and information supplied by an expanding community of developers.
Languages Supported: C, C++, Java, Perl, PHP, Python, Ruby and more
Notable Features:
  • A plethora of package solutions allowing for multi-language support
  • Java IDE enhancements such as hierarchical views of nested projects with customizable perspectives
  • Task-focused interface including system-tray notifications
  • Automated error reporting
  • Tooling options for JEE projects
  • JUnit integration
Drawbacks: While Eclipse is very versatile software, the many options may be intimidating to newcomers. Eclipse doesn’t have all of the same features as IntelliJ IDEA, but it is open source.

6. Code::Blocks

codeblocks ide banner
Code::Blocks is another popular free and open source option. It is a highly customizable IDE that performs consistently across all platforms, so it is great for developers who frequently switch between workspaces. The plug-in framework lets users tweak this IDE to meet their needs.
Languages Supported: C, C++, Fortran
Notable Features:
  • Easy-to-navigate tabbed interface including a list of open files
  • Compatible with Linux, Mac, and Windows
  • Written in C++
  • Requires no interpreted or proprietary languages
  • Supports many pre-built and custom-built plug-ins
  • Supports multiple compilers including GCC, MSVC++, clang and more
  • Debugger that includes breakpoint support
  • Text editor with syntax highlighting and autocomplete
  • Customizable external tools
  • Simple task management tools ideal for multiple users
Drawbacks: Though Code::Blocks comes with many features, it is a relatively lightweight IDE, so it’s not suited for larger projects. It is a great tool for beginners, but advanced coders may be frustrated with the limitations.

7. Aptana Studio 3

aptana studio ide banner
Perhaps the most powerful of the open source IDEs, Aptana Studio 3 is a massive improvement over its predecessors. Since Aptana Studio 3 supports most browser specs, compatibility challenges are minimal, so users can quickly develop, test and deploy web apps from this single IDE.
Languages Supported: HTML5, CSS3, JavaScript, Ruby, Rails, PHP, and Python
Notable Features:
  • Code assist for CSS, HTML, JavaScript, PHP and Ruby
  • Deployment wizard with simple setup and multiple protocols including Capistrano, FTP, FTPS and SFTP
  • Automatically sends Ruby and Rails applications to hosting services
  • Integrated debuggers for Ruby and Rails and JavaScript
  • Git integration
  • Easily accessible command line terminal with hundreds of commands
  • String custom commands to extend capabilities
Drawbacks: Although Aptana works well for students juggling multiple small projects, it has stability issues and runs slowly, so professional developers might prefer a more powerful IDE.

8. Komodo

komodo ide banner
Komodo offers a free 21-day trial and costs between $99 - $1615 depending on the edition and licensing. Practically any programmer can use Komodo because it supports most major programming languages. The streamlined interface allows for advanced editing, and small perks like the Syntax Checker and single-step debugging make Komodo one of the most popular IDEs for web and mobile development.
Languages Supported: CSS, Go, JavaScript, HTML, NodeJS, PerlPHP, Python, Ruby, Tcl and more.
Notable Features:
  • Customizable UI including split view and multi-window editing
  • Version control integration for Bazaar, CVS, Git, Mercurial, Perforce and Subversion
  • Python and PHP code profiling
  • Convenient code collaboration for multi-user editing
  • Deploy to the cloud thanks to Stackato PaaS
  • Graphical debugging for NodeJS, Perl, PHP, Python, Ruby and Tcl
  • Autocomplete and refactoring
  • Consistent performance across Mac, Linux and Windows platforms
  • Many add-ons allow a high level of customization
Drawbacks: One of the few complaints about Komodo is that the free version doesn’t enable all of the features, but the premium version is still considered well-worth the cost.

9. RubyMine

rubymine ide banner
RubyMine is another premium IDE, developed by Jet Brains, that offers a 30-day free trial and costs $210 - 687 annually. As its name implies, RubyMine is a favorite among Ruby enthusiasts; however, this IDE supports other programming languages as well. Easy navigation, logical workflow organization, and compatibility with most platforms make RubyMine a workplace favorite.
Languages Supported: CoffeeScript, CSS, HAML, HTML, JavaScript, LESS, Ruby and Rails, Ruby and SASS
Notable Features:
  • Code snippets, autocomplete and automatic refactoring
  • Project tree allows for quick code analysis
  • Rails Models Diagram
  • Rails Project View
  • RubyMotion allows for iOS development
  • Stack support includes Bundler, pik, rbenv, RVM and more
  • JavaScript, CoffeeScript and Ruby debuggers
  • Integration with CVS, Git, Mercurial, Perforce and Subversion
  • Bundled keyboard schemes
Drawbacks: Your machine needs at least 4GB of RAM for RubyMine to run smoothly. Some users also complain about the lack of GUI customization options.

10. Xcode

xcode-ide-banner
Xcode IDE is free, open-source, and part of Xcode, which is a collection of tools for making apps for Apple devices such as the iPad, iPhone and Mac. Integration with Cocoa Touch makes development in the Apple environment a breeze, and you can enable services such as Game Center or Passbook with a single mouse click. Built-in communication with the developer’s website helps users produce fully functioning apps on the fly.
Languages Supported: AppleScript, C, C++, Java, Objective-C
Notable Features:
  • UI controls can be easily connected with implementation code
  • Apple LLVM compiler scans code offers advice for addressing performance issues
  • Assistant function allows for split-code workspace
  • Jump bar permits quick navigation
  • Interface Builder lets user build prototypes without writing any code
  • UI and source code can be graphically connected to sketch complex interface prototypes in just minutes
  • Version Editor includes log files and commit timeline
  • Branch and merge for distributed teams
  • Test Navigator lets you quickly test applications at any point during development
  • Automatically builds, analyzes, tests, and archives projects thanks to Integration with OX X server
  • Workflow is highly customizable with Tabs, Behaviors, and Snippets
  • Instrument library and asset catalog

Featured Post

All Answers of Quiz regarding to this course on Fiverr "Online Freelancing Essentials: Be A Successful Fiverr Seller"

To Clear All quiz of mentioned Course you can have a look on or check questions answers as well. Course name:  Online Freelancing Essentials...

Popular Posts