Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 18 Mar 2012
Offline Last Active Dec 25 2013 01:03 PM

Topics I've Started

Android Development - More Java, Less hand-holding

14 December 2013 - 05:11 AM

Okay....I really dislike the whole Eclipse with ADT set-up.  Drag and drop stuff onto a graphical representation of a phone/tablet, figure out where the code goes....not for me.  I'd rather just write everything by hand.  Is there any way to write Android apps without having that rediculous set-up?


Android apps are written in Java...great I thought, I already know Java.  But the Eclipse/ADT set-up looks rediculous to me.  I'd rather just know where the program entry point is, import/create the necessary files, hand-code the UI using the API and compile to an apk.


I'll admit I haven't messed around with it a whole lot...because I want to write code....not drag things onto the screen and set their properties. 


I like Eclipse for regular PC applications.  You create the main class, give it a main() and you're good to go.  You want a GUI....import swing, set up the window with Frames and the like and you're good to go.  Took me an hour to understand that and a week to master (I'll fully admit I'm no Swing expert...but I can get a UI looking and behaving the way I want).  Android development....not as easy...at least not to me. 


I feel like I have to not only learn the Android API, but also how to use Eclipse/ADT's goofy interface.  It also doesn't really outline a clear code-path.  I assume most apps are event-driven so there wouldn't be a clear code-path - but still, I'd rather know how all that fits together and have the code arranged in a way that makes sense to me for a particular project. 


All I want to do is write a calendar app thats tailored to keeping track of my homework.  I have the entire design of this app already worked out in my head.  On a computer It'd take me at most 2 days to program it, and another day or 2 to debug and flesh out any major bugs.  A great starting app for android I thought - Simplistic, useful, and a perfect use of my free time between semesters.  I don't even know where to begin.  Normally I'd start writing the classes for everything, then design the UI, and then attach the UI to the underlying objects.  I can't even figure out how to get things to orient themselves the way I want.  I'd rather just write code that says create a textbox, position it this way (ie. LayoutManager), set this property to this, etc. 


Is there anyway to create an android app strictly from writing code? No drag and drop, no running through 100's of files to find the one that holds the code for the one thing I want to write.  Just pure code. 


Android is built on Linux, is all about open-source, a hacker/tinkerer's dream - not to mention all the cool sh*t inside the devices...like the accelerometer, HD camera, NFC, bluetooth, Wi-Fi....I guess I was expecting power tools, not fisher-price. 


Can anyone link me to some tutorials that show how to write Android apps independent of an IDE.  I'd much rather write the XML files by hand and compile by command-line than figure out how to use a UI that looks like it was designed for a spastic toddler.  I'm starting to realize just why the Google Play store is plagued with moustache-trimming games and fake broken screen apps.  It's really frustrating.


Thanks in advance to anyone that can point me in the right direction.


PS - I prefer textual information over videos, but I'll take whatever I can get.

Best way to check endianness at run-time?

06 March 2013 - 07:42 PM

Okay first off I found this:

bool endianness() {
     int i = 1;
     char *ptr;
     ptr  = (char*) &i;
     return (*ptr);

I like the way this is done, it's clever, quick and gets the job done.  Except it only really works if the size of an int is at-least twice the size of a char.  As I understand it the data types don't have a set size and that each 'larger' data type only has to be greater than or equal to the 'next smallest' data type.  Considering endianness is architecture specific, and the size of data types would differ on different architectures, this seems to be an unsafe assumption. 


There's a lot of garbage information out there on endianness but from what I've gathered (and please correct me if I'm wrong):


char isn't guranteed to be one byte, it seems it's usually the size of whatever the processor processes things in, which is sometimes 16-bit (2 byte) increments


integer can be 1 byte on some architectures, which would break this code


I also have one question, is endianness byte ordering always based on 8-bit bytes or would it be ordered in sections of 16-bits on architectures with 16-bit chars?


I'm trying to accomplish something like this (pseudo-code):


ENDIANNESS getEndian()

     get a 2 byte numeric data type;

     set bytes value equal to 1;

     get first byte

     if ( first byte == 0)
          e = BIG_ENDIAN
    else  if ( first byte == 1)
          e = LITTLE_ENDIAN

     return e;



Just not sure the best way to handle this, especially since I'm unclear on whether the byte order is based on 8-bits always (seems unlikely) or whatever the size of a char is on the system executing the code (seems more likely). 


Any help is greatly appreciated :)

Possible C++ scope issue with class and vector of pointers

12 January 2013 - 10:31 AM

Alright it's been a while since I've programmed in C++ so this could be a simple fix but I'm just not seeing it. 


I'm using Allegro 5, I have a main.cpp, a character.h, and a character.cpp


I have some test code in my main.cpp that works as it should:

ALLEGRO_BITMAP *characterSpriteSheet = al_load_bitmap("CharacterSpriteSheet.png");
characterAnimation walkingDown(6, 32, 32, 0, characterSpriteSheet);
std::vector <ALLEGRO_BITMAP*> testvector(1);
testvector[0] = al_create_sub_bitmap(characterSpriteSheet, 0, 0, 32, 32);

and then in the main game loop:

al_draw_bitmap(al_create_sub_bitmap(testvector[0], 0, 0, 32, 32), 0, 0, 0);

al_flip_display();  //Blit to screen


al_create_sub_bitmap creates an ALLEGRO_BITMAP* object that shares the same memory but with different size / clipping.



my character.h looks like this:


#include "allegro5/allegro.h"

#include <vector>
#include <string>

class characterAnimation
    characterAnimation(short int numOfSteps, short int height, short int width, short int row, ALLEGRO_BITMAP *spriteSheet);
    ALLEGRO_BITMAP *getNextFrame(void);
    short int numberOfSteps;
    short int currentStep;
    short int imageHeight;
    short int imageWidth;
    short int row;
    std::vector <ALLEGRO_BITMAP*> images;



my character.cpp looks like this:

#include "character.h"

characterAnimation::characterAnimation(short int numOfSteps, short int height, short int width, short int animationRow, ALLEGRO_BITMAP *spriteSheet)
    numberOfSteps = (numOfSteps - 1);
    currentStep = 0;
    imageHeight = height;
    imageWidth = width;
    row = animationRow;
    std::vector <ALLEGRO_BITMAP*> images(numberOfSteps);

    for(int x = 0; x <= numberOfSteps; x++)
        images[x] = al_create_sub_bitmap(spriteSheet, (imageWidth * x), (imageHeight * row), imageWidth, imageHeight);


 the characterAnimation::getNextFrame(void) function is currently setup just to return the first element (0) of the vector to make things easier right now (since it's not working)


The problem seems to be in characterAnimations constructor - I'm thinking that the al_create_sub_bitmap() created pointers goes out of scope and gets destroyed possibly at the end of the constructor? resulting in a bunch of pointers that don't go anywhere sensible.  Which would explain why my program crashes when I try to call al_draw_bitmap(images[x]).  My question is, is that what's happening?


Currently my program crashes only when I try to draw an element from characterAnimation::images to the screen, For some reason these pointers aren't getting set, or are being destroyed, I have no idea why though, so any help would be awesome.