Wednesday, 12 March 2014

Project 2: Mouse and Keyboard control through Android device


Accelerometer and gyrometer are costly. And they were necessary for my master project (the one I mentioned in Last blog) . Spending money to buy them and then a microcontroller for interacting with them would have cost me heavily.
Android <> PC interaction

I knew most of android phones have these sensors in-built. So instead of spending ( around 10k rs) I thought of studying android api , and then building an app which would send sensor data to the computer.

Android was surprisingly easy to learn. Luckily, because we had learned Java in 3rd semester. I started building small apps and was able to fetch and display sensor data. But then came the difficult part “making a connection to a remote computer”. There are many modes of communication, but I preferred 2 of them Bluetooth and WLAN.

I didn’t have any android phone. I was trying out my apps on Micromax Funbook p275 , a cheap but useful tablet. It didn’t have Bluetooth module, so I had to go with wifi. It took me some time to learn Sockets because I had no freaking idea how computer networks worked.  And yeah Java doesn’t allow sockets to be created on main thread, so I had to learn thread programming too.
I preferred Java on remote server (your PC) because it has a common VM for linux, windows or OSX. 

When I was browsing through Java library, I came across an awesome class ‘Robot’. Its functionality is as cool as its name , It can simulate mouse movement and key presses……..
I already knew ‘making connection with a remote computer’ , ‘sending data’ and Robot class gave me  the idea of controlling my computer with my tablet. I implemented it , and here’s the output..

I continued working on this project for 2-3 months and added features like automatic server detection (requires UDP broadcasting), Bluetooth support and what not!



Saturday, 8 March 2014

My First Project: A First Person Shooter Game





I knew C language before my Engineering course. As a first year student of Computer Science, I had no idea how things are going to be in CSE.

First year didn’t help much. During my second year I started trying out things. Eager to make my own game, I made a snake game with no knowledge of any of the graphics libraries. How? With the use of char matrix as the view port, linked list for the snake, ’o’ as the snake body and ‘*’ as the fruit. 
My first application ‘A Snake Game‘ in C

Why First Person Shooter Game ?

Ever since my first year (2011), I had a master project in my mind. A wearable display (with accelerometer and gyroscope) to track rotation and tilt. And a motion controller to track hand movement (Wouldn’t it be cool if you were the protagonist in your favorite FPS game, and you could look around, and shoot your enemies by mere physical movements). It was this project that inspired me to work on most of the projects that followed.
'The Master Project'
I planned to work on this project with one of my friend (doing Electronics Eng.), I were to focus on the software part and He on the hardware. So I thought of building my own game to interact with the hardware.


Decision: Design a game or Simulate key presses

I could simulate mouse movements and key presses with signals from sensors (space = jump , left click = 
shoot etc.)(so that I could run any of the FPS games) but major flaw was that the player’s hands are fixed to the camera (there is no independent movement of head and hands). Because that was the most important thing, as we head separate sensors to track head movement and hand movement, I thought of making my own game.




Game engine, which one?

It was absurd to build my own game engine and then build a game, so I started searching for the best readymade game engine for me, which was easy and gave me enough freedom. I went through Unity, Ogre3D, Panda3D and then finally found the perfect game engine “BLENDER”. Blender is free and open source and allowed me to design characters and side by side script their logic in Python. You don’t need me, to tell you how cool python is… right?



Blender, Done! What next?

I studied blender’s documentation and followed their video tutorials. Found a nice enough character, rigged it. I couldn’t attach mouse triggers for ‘looking’ because it would be triggered by our sensors.
It took me nearly 2 months to finish my first Project-level application.
And I was happy with the output…


Download
Extract and Run 'Enemyscript.exe'

Keys:
W: move forward
I, K, J, L: look up, down, left, right
Space: reposition after looking
Shift: jump
Numpad 8, 2, 4, 6: move gun up, down, left, right
R: reload







About me



Hi! I am Sushant Raikar,a B.Tech. student of National Institute Of Technology , Goa. 

In this blog I will be discussing the projects I have done and what drived me to do those projects during my engineering course.

As a child ,I was a computer freak,(not in a geeky way I mean). I remember my dad bought a computer system, it had windows 98 OS and
a nice green windows background. He taught me how to use PowerPoint and As a cartoon lover ,I created an animation ( Pokemon ) with it
by drawing each frame in Paint and pasting it. And Yeah, the awesome games we had that time (bomber boy, Tank , wolfestein ...), I was so obsessed with those games and I am sure that they cannot be replace by any of the latest, high Graphics games in my memory.

I started my programming with c ,then c++ and many other languages followed. Actually I didn't study those languages independently,
but when I felt their need when doing projects.

I will try to keep the projects I have done in a timeline so that they are in a proper flow.