Archive

Archive for the ‘Programming’ Category

MapApp2 : App Design

10/03/2012 4 comments

Welcome to the third part of my tutorial on how to create a map app for Android without using Google™ APIs :).

Series outline:

______________________________________

Okay, I’m supposed to show you a class diagram here but I changed my mind, since the app is simple I’ll explain each class in some lines :).

TilesManager: this class contains all the calculations needed to power our app, as I mentioned before maps are made up of tiles, we need to know exactly what tiles to fetch, we also need to convert latitude and longitude to pixel coordinates to display markers, this class by itself doesn’t contain the tiles, it just provides us with methods to Read more…

Categories: Android, Maps, Programming Tags: , ,

MapApp1 : Theory you need to know

09/03/2012 4 comments

Welcome to the second part of my tutorial on how to create a map app for Android without using Google™ APIs :).

Series outline:

______________________________________

In this part I’ll give simple information about maps and some terms and how they are used, hopefully saving you some time of searching.

Since I’m not a geography expert, please note that some information here might not be accurate, corrections are welcome 🙂 after all I’m just a programmer who learned what he needs to accomplish his goal.

I’ll provide additional links for further reading at the end of this post.

Earth shape : although the earth isn’t a perfect sphere, some map systems treat it as a sphere, I guess that’s okay for everyday use.

Map projection : from Wikipedia: “A map projection is any method of representing the surface of a sphere or other three-dimensional body on a plane. Map projections are necessary for creating maps. All map projections distort the surface in some fashion. Depending on the purpose of the map, some distortions are Read more…

Categories: Android, Maps, Programming Tags: , ,

Building an offline map app for Android

09/03/2012 182 comments

Hello there :), this tutorial series is about building a very simple map application for Android from scratch and without using Google™ APIs

(Don’t get frightened by the scroll bar of your browser 😀 the comments made this post look long 😀 )

The main app features will be:

  1. Displaying a map stored in a database on the SDcard, in other words : offline* map, no internet connection is required (but easy to implement online functionality).
  2. User can touch control the map (Panning), zoom in\out using volume keys.
  3. A marker will be displayed on the map depending on the user’s GPS position.

*Update 16/8/2012: online maps are now supported in tutorial part 6

as mentioned before : we’re not going to use Google™ APIs.

As you can see the app will be simple, other more complex functions can be added later.

Q: Why not use Google™ maps APIs (eg: MapActivity)?
A: it requires a working internet connection.
A: you might want to write your own classes.
A: you might want to know how things work.

Q: Aren’t there free map apps on the Android Market?
A: Yes there are and they are really good ones, Locus Free, RMaps, Orux Maps, these apps can run with both online and offline modes, I mainly use Locus Free, but I like writing my own apps and learn new things.

before starting this tutorial I’ll show you the final result, so that you can decide whether  to continue reading or not

The app and the tutorials target API Level 7 as a minimum SDK (That’s Android 2.1 )

MapApp Screenshot

A screenshot from the emulator
(I’m not really in Madagascar, just picked a random point :P)

Here’s the source code (Eclipse Project) and the apk file, after you install it on your device\emulator, copy this map file world.sqlitedb to your /sdcard/mapapp/ (You’ll need to make the folder yourself).
Read more…

Categories: Android, Programming Tags: , ,

FuchsGUI Update

09/08/2011 Leave a comment

Hello there, sorry for being inactive lately but I don’t feel like programming or learning something new :(.

Anyway, I fixed the issue in FuchsGUI where some text was blurry, the reason was that the text was being rendered with floating point values for position, something like (20.3f,29.4), this meant that spriteBatch should split physical pixels :(.

Anyway, thanks to a guy named Fab who told me how to fix this, the solution was something like this:

position.X = (int)Position.X;
position.Y = (int)Position.Y;
// Render here

So, here’s the fixed version (XNA4 only):

   FuchsGUI v1.1 Source Bin XNA4 (Blurry Text Fixed)

I hope to see you later :)…

RobotWarz Alpha Release

23/07/2011 9 comments

RobotWarz

Introduction (a boring one maybe 😉 ?)

Good morning\evening or whatever suites your timezone :).
I’ve been waiting for this :D!, I’ve finished programming the alpha release of the game.
The reason I’m publishing it right now is because It might take me some time to have a full game, so by publishing an alpha release I can get opinions & suggestions from people which will encourage me to complete the game.

This release isn’t meant for end-users but rather for fellow programmers.

Unfortunately my laptop doesn’t have a graphics card so Read more…

Stay tuned :P

02/07/2011 Leave a comment

Three videos of my game RobotWarz are coming soon…
One week after that I will publish the game here on the blog 😛

Here are two screen shots 😉

RobotWarz, AI Attack

AI opponent attacking the player

 

RobotWarz_AI War

AI robots are fighting each other, player is in Spectator Mode.

XNA Fuchs InputHandler

22/03/2011 2 comments


Introduction:

Each XNA “Game” I program I have to take input, something like the following


KeyboardState prevKeyboardState;

protected override void Update(GameTime gameTime)
{
    KeyboardState keyboardState = Keyboard.GetState();

    if (keyboardState.IsKeyDown(Keys.Left) && prevKeyboardState.IsKeyUp(Keys.Left))
    {
        // Do stuff
    }

    prevKeyboardState = keyboardState;
}

I have to create two KeyboardStates, one for this frame & the other is for the previous frame. Then in most cases I check that some button is pressed only in a frame not in its predecessor…( because even if you press a button and remove your finger quickly the, button will be considered pressed in more than one frame )

Same issue goes for the mouse.

So I thought I should create my own input handler, Read more…

File To Image Converter

18/03/2011 Leave a comment

When I run out of programming ideas I program some weird & sometimes useless stuff just for fun :D.

This program converts a file into a bitmap and then saves it as a Png\Bmp image, the file then can be retrieved (along with its name) from the image.

FileToImageConverter

A 7MB file converted into an image

The idea is that each pixel in the bit map contains 3 components ( Red, Green, Blue), each one of them Read more…

Categories: My Thoughts, Programming

Fuchs Navi Wheel – A Creative way of steering a car in a game

01/03/2011 Leave a comment


Introduction:

One day while I was studying for an exam then an idea came to my mind!
Wouldn’t it be cooler to use the touchpad to steer a moving car (instead of the boring Left\Right keys)?

I’m not a big fan of racing games but I liked the idea…
To simulate rotating a real steering wheel the player should create circles on the touchpad, counter-clockwise (ccw) to steer left, clockwise (cw) to steer right.

FuchsNaviWheel

Steering left using the touchpad

Moving the finger in such a way should continuously steer left


Read more…

XNA FuchsGUI part V

16/02/2011 6 comments

___________________________________________________

1-Introduction to the GUI.
2-Hello control :D.
3-Hello form.
4-Exporting forms easily from Microsoft Visual Studio Designer to FuchsGUI :D.
5-The future of FuchsGUI & some notes.

___________________________________________________

This part of the tutorial is the last part of the series..

I don’t know how to organize this post since it’s not a tutorial 😉 so I’ll start with some notes on FuchsGUI.

FuchsGUIDemo

A post without an image is a dull post 🙂


Textures & Fonts:

As you saw each control takes a Texture2D parameter in the constructor, well… having many textures might have a bad impact on performance, because if you first draw a Button and then a TextBox the GPU will have to change textures.

A better solution is Read more…