Posts Tagged ‘Code Snippet’
Posts that have small parts from a bigger code.
Android: Loading and playing videos from different sources
Posted by Dimitri | Filed under Featured, Programming
This is the 41st post on the website! It explains how to load images from a variety of locations, such as the ‘Resources’ folder, the SD card and from a remote server. As usual, the source code is available for download at the end of the post.
Let’s start with the basics: video formats. At the time this is being written, Android supports .3gp and .mp4 video files encoded as H.263,H.264 and MPEG-4 SP file formats. For an updated list, visit this link.
Android: loading images from a remote sever, SD card and from the Resources folder
Posted by Dimitri | Filed under Programming
As stated on the title, this post will explain how to load a image from 3 different sources: the SD card, from a remote server and from the Resources folder. Since the methods and code used to load these images from these sources are different from one another, this post is going to be divided into three different parts, one for each location.
Select one of the following links to go to a specific part of the post: (more…)
Android: touchscreen ‘swipe’ movement detection
Posted by Dimitri | Filed under Programming
This post explains how to code a simple swipe screen movement detection that can be used to control characters and other objects on an Android game or any other application.
All this code is written inside the View class, so open it up and let’s get to it. The first thing we will have to do is to create four different variables: one pair will store where the screen was touched, and the other one will be used to store the difference between the location where the screen has been pressed and where the screen has been released. Create this variables and assign zero to all of then, like this: (more…)
Unity3D: Troubleshooting Rigidbody problems
Posted by Dimitri | Filed under Programming
Maybe the component that give Unity3D developers the most number of headaches is the Rigidbody. Sometimes it doesn’t seem to not work the way it’s supposed to, although these problems are mostly caused by wrong parameter values and settings. That’s the main reason behind this post: to point out the most common problems encountered when using rigidbodies in Unity3D.
Before listing these problems, keep in mind that the Rigidbody is part of the physics simulation in Unity3D which is decoupled from the game logic, and that’s why there is a separated Physics Time Step and a different method dedicated to it- the FixedUpdate() method. And before trying to figure out what the problem is, check the basics and see if all GameObjects the Rigidbody collides with have an attached Collider component, or if some parameter is set too high or too low.
Game Programming Basics: Moving an element
Posted by Dimitri | Filed under Programming
This post explains some of the most basic game programming techniques: how to move elements on the screen. If you already know this, please skip it, or add something to this post in the comments. Since these lines of codes are trivial to game programming, it may be one of the reasons why it is so hard to find a post or a website explaining them. The code presented on this post isn’t the only way to move objects in a game and certainly there is a lot more information out there. The intention of this post is to serve as a starting point.