Search Results

Search found 6 results on 1 pages for 'semajhan'.

Page 1/1 | 1 

  • Android game logic problem

    - by semajhan
    I'm currently creating a game and have a problem which I think I know why it is occurring but not entirely sure and even if I knew, don't know how to solve. I have a 2D array 10 x 10 and have a "player" class that takes up a tile. Now, I have created 2 instances of the player and move them around via swiping. Around the edges I have put "walls" that the player cannot walk through and everything works fine, until I remove a wall. Once I remove a wall and move the character/player to the edge of the screen, the player cannot go any further. The problem occurs here, where the second instance of the player is not at the edge of the screen but say 2 tiles from the first instance of "player" who is at the edge. If I try moving them further into the direction of the edge, I understand that the first instance of player wouldn't move or do anything but the second instance of player should still move, but it won't. This is the code that executed when the user swipes: if (player.getArrayX() - 1 != player2.getArrayX()) { player.moveLeft(); } else if (player.getArrayX() - 1 == player2.getArrayX() && player.getArrayY() != player2.getArrayY()) { player.moveLeft(); } if (player2.getArrayX() - 1 != player.getArrayX()) { player2.moveLeft(); } else if (player2.getArrayX() - 1 == player.getArrayX() && player2.getArrayY() != player.getArrayY()) { player2.moveLeft(); } In the player class I have: public void moveLeft() { if (alive) { switch (levelMaster.getLevel1(getArrayX() - 1, getArrayY())) { case 0: break; case 1: subX(); // basically moves player left setArrayX(getArrayX() - 1); // shifts x coord of player 1 within tilemap Log.d("semajhan", "x: " + getArrayX()); break; case 9: subX(); setArrayX(getArrayX() - 1); setAlive(false); break; } } } Any help on the matter or further insight would be greatly appreciated, thanks.

    Read the article

  • Android threads trouble wrapping my head around design

    - by semajhan
    I am having trouble wrapping my head around game design. On the android platform, I have an activity and set its content view with a custom surface view. The custom surface view acts as my panel and I create instances of all classes and do all the drawing and calculation in there. Question: Should I instead create the instances of other classes in my activity? Now I create a custom thread class that handles the game loop. Question: How do I use this one class in all my activities? Or do I have to create a separate instance of the extended thread class each time? In my previous game, I had multiple levels that had to create an instance of the thread class and in the thread class I had to set constructor methods for each separate level and in the loop use a switch statement to check which level it needs to render and update. Sorry if that sounds confusing. I just want to know if the method I am using is inefficient (which it probably is) and how to go about designing it the correct way. I have read many tutorials out there and I am still having lots of trouble with this particular topic. Maybe a link to a some tutorials that explain this? Thanks.

    Read the article

  • Android threads trouble wrapping my head around design

    - by semajhan
    I am having trouble wrapping my head around game design. On the android platform, I have an activity and set its content view with a custom surface view. The custom surface view acts as my panel and I create instances of all classes and do all the drawing and calculation in there. Question: Should I instead create the instances of other classes in my activity? Now I create a custom thread class that handles the game loop. Question: How do I use this one class in all my activities? Or do I have to create a separate thread each time? In my previous game, I had multiple levels that had to create an instance of the thread class and in the thread class I had to set constructor methods for each separate level and in the loop use a switch statement to check which level it needs to render and update. Sorry if that sounds confusing. I just want to know if the method I am using is inefficient (which it probably is) and how to go about designing it the correct way. I have read many tutorials out there and I am still having lots of trouble with this particular topic. Maybe a link to a some tutorials that explain this? Thanks.

    Read the article

  • Android admob questions

    - by semajhan
    Nothing about how to implement ads via admob into an application or anything. I'm just new to ads and it's pretty confusing to get a good grasp on how it works. I've been wanting to put out an app with ads in it but have been reading you need to initially pay at least $50 to get started? I thought it was free to ad whatever ads to display on YOUR app. Or is the $ for adding your own advertising on OTHER people's apps? I'm so confused. Someone please enlighten me, thanks!

    Read the article

  • Android sql creating database once

    - by semajhan
    One thing i'm not understanding is how to create the database and data just once in an android application. I extend SQLiteOpenHelper and use a DataHelper class that to manipulate data. Now, I have addEvent() and updateEvent() within the DataHelper class. I create an instance of DataHelper in my Activity and addEvent() a couple of times to insert data. Well, now I don't know how to just do that once. If I restart the app, its just going to "addEvent()" again and so the data is being reset every time. Sorry for the probably really REALLY noob question. The only solution I found was not using the DataHelper class and just adding data "manually" within the onCreate() method in SQLiteOpenHelper.

    Read the article

  • Android java assigning 2d array to 3d array

    - by semajhan
    I'm running into problems trying to assign a 2d array to a 3d array, so I thought i'd ask a question about 3d and 2d arrays. Say I have a masterArray[][][] and wanted to put childArray1[][] and childArray2[][] into it. This is how I have done it and was wondering if that is the correct way of applying it: private int[][][] masterArray; private int[][] childArray1 = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 0, 1, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 8, 1, 0, 1}, {1, 0, 7, 1, 1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 9, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1} }; private int[][] childArray2 = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, {1, 1, 1, 1, 7, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 0, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 0, 0, 0, 1, 1, 1}, {1, 1, 1, 9, 1, 1, 8, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, }; Ok, so in my init method I use these some methods to set the child arrays into the master array. What I was curious about was how this exactly works. I assumed the following: masterLevel = new int[MAX_LEVELS][MAP_WIDTH][MAP_HEIGHT]; for (int x = 0; x < MAP_WIDTH; x++) { for (int y = 0; y < MAP_HEIGHT; y++) { masterArray[currentLevel][x][y] = childArray1[x][y]; } } Would that work? In my application things aren't working so I picking out code that I am not 100% sure on.

    Read the article

1