input
stringlengths
10
828
output
stringlengths
5
107
public int get kills return m kills
retrieve the total number of kills a player has earned
public void use weapon weapon type weapon m game thread get game state get current player set weapon weapon set weapon weapon
use the given weapon
public void increment kills int delta kills m kills delta kills
increment the total number of kills a player has earned
public void do stop synchronized m surface holder log d game thread do stop shutting down m running false
stop running if we are
public void set powerups item type items m power up display remove all views for item type i items image view icon image view get layout inflater inflate r layout icon null margin layout params layout new view group margin layout params 32 32 layout set margins 1 1 1 1 icon set layout params new linear layout layout params layout icon set image resource i get icon m power up display add view icon
set the list of powerups currently available
public void increment damage dealt int delta damage m damage dealt delta damage
increment the total amount of damage a player has caused
public void do pause synchronized m surface holder log d game thread do pause suspending main loop m paused true
pauses the physics update animation
public void use powerup item type item todo change this to call some sort of use item function in scorched player for now we just display the item activated set powerups new item type item
use the given powerup item
public void hide hud m hud set visibility view invisible
hide the hud from display
public void use game state in extras synchronized m surface holder m game state game state game activity m context get intent get extras get serializable game state if m game state null log e game thread use game state in extras deserialized state is null for scorched player player m game state get players player init player m context
initialize game state passed in by the intent bundle
public void show hud m hud set visibility view visible
show the hud
public tank type get tank type return m tank type
getter method for the players tank type
public void next turn if m game state start next turn if m game state get players size 1 for scorched player winner m game state get players if winner is alive winner increment cash game state cash per win end current round else m already counted shot as hit false refresh hudplayer
begin the next players turn
public int get shots taken return m shots taken
retrieve the number of shots a player has taken in the entire game
public void increment shots taken m shots taken
increment the total number of shots the player has fired
public void end current round intent i new intent if m game state get current round m game state get num rounds go to shop screen i set class m context shop activity class else game over i set class m context results activity class i put extra game state m game state game activity m context start activity i game activity m context finish
end the current round of play
public int get shots hit return m shots hit
retrieve the total number of the players shots that have it
public void next round m game state start next round set virtual size m game state get terrain get width m game state get terrain get height refresh hudplayer
start the next round
public void increment shots hit m shots hit
increment the total number of shots that the player has hit
public weapon type get current weapon todo implement method return weapon type baby missile
retrieve the type of the current weapon in use
public void center camera at int x int y m scroll x bound int x m surface width 2 m virtual width m surface width 0 m scroll y bound int y m surface height 2 m virtual height m surface height 0
move the scrolled position so the camera is focused on a particular point
public int get weapon ammo todo implement method return 1
retrieve the number of missiles available for the currently selected weapon
public explosion get weapon explosion int weapon idx todo implement method return null
get an explosion type for a particular weapon
public int get tank height return tank height
retrieve the height of the tank
public int get tank width return tank width
retrieve the width of the tank
public void do scroll float dx float dy if math abs dx min scroll threshold m scroll x bound int int m scroll x dx scroll sensitivity m virtual width m surface width 0 if math abs dy min scroll threshold m scroll y bound int int m scroll y dy scroll sensitivity m virtual height m surface height 0
scroll the screen
public int get tank color todo implement method return m color
retrieve the color of the tank
public void do fling float velocity x float velocity y m scroller fling m scroll x m scroll y int velocity x int velocity y m virtual width m surface width 0 m virtual height m surface height 0
handle the fling event scrolling the screen as necessary
public boolean is alive return m health 0
see if the player is currently alive or not
public void stop fling m scroller force finished true
force the fling momentum to stop
public void set surface size int width int height synchronized to make sure these all change atomically synchronized m surface holder m surface width width m surface height height
callback invoked when the surface dimensions change
public void set weapon int weapon idx todo implement method
set the weapon to be used on the next turn
public void set virtual size int width int height synchronized to make sure these all change atomically synchronized m surface holder log d game thread set virtual size width x height m virtual width width m virtual height height
set the virtual size of the screen
public void use item int type int arg todo implement method
use a non weapon item in a players inventory
public void activate shield int shield type todo implement method
activate a players shield
public void activate parachute todo implement method
activate a players parachute
public void activate tracer todo implement method
set the tracers to active to use on a players next turn
public void activate battery int power todo implement method
activate the players battery supply to increase the users max power
public void set game thread game thread gamethread m game thread gamethread
set the game thread which is associated with the activity
public void start m media player start
starts the sound playing
public void stop throws illegal state exception ioexception m media player stop m media player reset m media player prepare
stops the sound from playing and resets the sound to be played again
public boolean use tracer todo implement method return false
make sure a tracer is available and use one for this turn
protected void fire weapon s game thread fire weapon
function for subclasses to use to fire their weapons
public game state get game state return m game state
retrieve the game state associated with the game thread
protected terrain get terrain return s game state get terrain
function for subclass to use to retrieve the terrain
public void decrement weapon todo implement method
decrement the number of missiles available from the current weapon by one
protected int deflect int angle if deflection 0 int prob new random next int 50 if prob 30 return angle deflection if prob 20 return angle deflection return angle
randomly deflect angle to make ai suck
private double get sqrt int power double delt x double delt y double sqrt math sqrt math pow power 4 scaled gravity scaled gravity delt x delt x 2 delt y power power if sqrt double na n log d ross ai sqrt is na n log d ross ai sqrt is sqrt return sqrt
helper function to clear up math problems
public int get health return m health
retrieve the current amount of health the player has
protected boolean can hit coordinates target int r int int math pow this get health 2 scaled gravity if math abs target m x this get x r return false return true
check to see if ai has enough power to hit target
public void test top for int i 0 i m bitmap get width i for int j 0 j 50 j if m bitmap get pixel i j color transparent fail if m terrain is terrain i j fail
test the top row of the terrain
public void test bottom for int i 0 i m bitmap get width i for int j m bitmap get height 100 j m bitmap get height j if m bitmap get pixel i j color transparent fail if m terrain is terrain i j fail
test the bottom row of terrain
public void set health int health m health health m power math min m power m health 10
set the current players health
public void test height map bounds sine wave terrain generator itg new sine wave terrain generator itg generate terrain int itg height map itg get height map for int i 0 i itg height map length i assert true itg height map i sine wave terrain generator min height assert true itg height map i sine wave terrain generator max height
test the height bounds of the map
public scorched player find closest target array list scorched player players get players scorched player player null double best distance 1 0 for scorched player candidate players if candidate equals this continue if player null player candidate best distance get distance candidate get x candidate get y this m initial x this m initial y else if get distance candidate get x candidate get y this m initial x this m initial y best distance player candidate best distance get distance candidate get x candidate get y this m initial x this m initial y return player
returns the player closest to the attacker
public scorched player find weakest target array list scorched player players get players scorched player player null for scorched player candidate players if candidate equals this candidate is alive continue if player null player candidate else if candidate get health player get health player candidate return player
returns the player with the least health at the moment
public scorched player find strongest target array list scorched player players get players scorched player player null for scorched player candidate players if candidate equals this candidate is alive continue if player null player candidate else if candidate get health player get health player candidate return player
returns the player with the most health at the moment
public scorched player find most bounty target array list scorched player players get players scorched player player null for scorched player candidate players if candidate equals this candidate is alive continue if player null player candidate else if candidate get bounty player get bounty player candidate return player
returns the player with the most bounty on their head
public scorched player find richest target array list scorched player players get players scorched player player null for scorched player candidate players if candidate equals this candidate is alive continue if player null player candidate else if candidate get cash player get cash player candidate return player
returns the player with the most money
public int apply turn damage set health m health m turn damage int damage m turn damage reset damage return damage
apply the total damage to a player at the end of a turn
public scorched player find deadliest target array list scorched player players get players scorched player player null for scorched player candidate players if candidate equals this candidate is alive continue if player null player candidate else if candidate get kills player get kills player candidate return player
returns the player with the most kills
public void test start round int state idx 0 game state state game states state idx add a garbage collect to free memory from previous tests system gc state start next round more asserts assert not equal null terrain after round begins null state get terrain int wind state get wind value if wind enabled state idx true assert true invalid wind value when enabled wind game state min wind value wind game state max wind value else assert equals expected wind error return value game state min wind value 1 wind
test some of the functionality of the rounds
public scorched player find darkest skinned target array list scorched player players get players scorched player player null for scorched player candidate players if candidate equals this candidate is alive continue if player null player candidate else if is darker player get color candidate get color player candidate return player
returns the player with the darkest color skin
public scorched player find lightest skinned target array list scorched player players get players scorched player player null for scorched player candidate players if candidate equals this candidate is alive continue if player null player candidate else if is darker player get color candidate get color player candidate return player
returns the player with the lightest color skin
public void set angle int angle m angle angle
set the current angle of a players turret
public void init player context context rebuild the transient variables init paint m bitmap bitmap factory decode resource context get resources r drawable tank android m turret base x 15 5f m turret base y 20 5f m turret length 8 m explosion new tank explosion context
initialize a player object re creating any transient variables as needed
public void set current boolean current m current current
set whether it is currently the players turn or not
public boolean is current return m current
retrieve whether it is currently the players turn or not
public void set power int power m power math min power m health 10
set the players power value
public int get power return m power
retrieve the players current firing power
public void set weapon weapon type weapon m weapon weapon
set the players active weapon
public weapon type get weapon return m weapon
retrieve the players current active weapon
public coordinates get coordinates coordinates coord new coordinates get x get y return coord
retrieve the position of a player in the form of a coordinates object
public void do start synchronized m surface holder initialize game here x 0 y 0 x2 320 64 1 y2 455 64 1 m last time system current time millis 100 set state state running
starts the game setting parameters for the current difficulty
public void do start synchronized m surface holder initialize game here m last time system current time millis 100 set state state running
starts the game setting parameters for the current difficulty
public void pause synchronized m surface holder if m state state running set state state stopped
pauses the physics update animation
public void set state int state synchronized m surface holder m state state
sets the game state running stopped
public void unpause move the real time clock up to now synchronized m surface holder m last time system current time millis 100 set state state running
resumes from a pause
public void surface created surface holder holder start the thread here so that we don t busy wait in run waiting for the surface to be created m thread set running true m thread start
callback invoked when the surface has been created and is ready to be
public void surface destroyed surface holder holder we have to tell thread to shut down wait for it to finish or else it might touch the surface after we return and explode boolean retry true m thread set running false while retry try m thread join retry false catch interrupted exception e
callback invoked when the surface has been destroyed and must no longer
public void do start synchronized m surface holder initialize game here x 10 y 10 m last time system current time millis 100 set state state running
starts the game setting parameters for the current difficulty
public string encrypt string data secret key secretkey cipher cipher string encrypted data null try cipher cipher get instance secretkey get algorithm cipher init cipher encrypt mode secretkey encrypted data new string org apache commons codec binary hex encode hex cipher do final data get bytes catch no such algorithm exception e e print stack trace catch no such padding exception e e print stack trace catch invalid key exception e e print stack trace catch illegal block size exception e e print stack trace catch bad padding exception e e print stack trace return encrypted data
symmetric encryption of a string
public boolean create user account dir string username string user dir system get property user home string seperator system get property file separator file helloworld dir new file hello world sub dir string user account dir hello world sub dir seperator username file user account new file user account dir if user account exists return false else if user account mkdir create subfolders file subdir new file user account dir seperator contacts subdir mkdir subdir new file user account dir seperator temp subdir mkdir subdir new file user account dir seperator temp seperator messages subdir mkdir return true return false
creates a new account subfolder for the given username
public void on create bundle icicle super on create icicle set content view r layout about
called when the activity is first created
public string get user account dir string username old version return system get property user home hello world sub dir system get property file separator username return hello world sub dir system get property file separator username
get the hello world directory
public boolean is user name available string user name file user account new file get user account dir user name return user account exists
checks if the user directory already exists this is important when
public boolean load account todo return false
loads and parses the user account using the global user name
public boolean save account account the account document doc new account parser parse account the account profile parser out export xml doc system out return true
saves the user account back to hard disk using the global user name
public boolean backup account string file name boolean encrypt todo return false
saves an backup of the user account with the given name
public boolean upload account todo return false
upload encrypted account to a server
public account create new account account account new account account set key pair this create key pair account set private profile new profile return account
create a new account
public boolean download account string url string username todo return false
download encrypted account from a server and create local folder
public sub profile create sub profile relation ship type type profile profile sub profile sp new sub profile hcard for relation ship type r profile get hcard get relation ship types if r get name equals type get name sp set hcard new hcard structured profile attribute build in attributes type profile get hcard break custom attributes if profile get relation ship types contains type here a recursive method is needed as a complex structure can be given sp get attributes add build in attributes type profile get attributes return sp
extracts all attributes from a given user profile to a sub profile that
public float get scale boolean focused int offset formula 1 2 offset return math max 0 1 0f float math pow 2 math abs offset
returns the size 0
public string get content type string type null try if url conn null url conn url open connection catch ioexception e if url conn null type url conn get content type if type null type application octet stream return type
returns the value of the url content type header field
public string get name return url get file
calls the code get file code method on the url used to
public input stream get input stream throws ioexception return url open stream
the get input stream method from the url
public output stream get output stream throws ioexception get the url connection if it is available url conn url open connection if url conn null url conn set do output true return url conn get output stream else return null
the get output stream method from the url
public input stream get input stream throws ioexception return new file input stream file
this method will return an input stream representing the
public output stream get output stream throws ioexception return new file output stream file
this method will return an output stream representing the