idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
3,200 | public static CollisionConfig imports ( Configurer configurer ) { Check . notNull ( configurer ) ; final Map < String , Collision > collisions = new HashMap < > ( 0 ) ; for ( final Xml node : configurer . getRoot ( ) . getChildren ( NODE_COLLISION ) ) { final String coll = node . readString ( ATT_NAME ) ; final Collisi... | Create the collision data from node . |
3,201 | public static Collision createCollision ( XmlReader node ) { Check . notNull ( node ) ; final String name = node . readString ( ATT_NAME ) ; final int offsetX = node . readInteger ( ATT_OFFSETX ) ; final int offsetY = node . readInteger ( ATT_OFFSETY ) ; final int width = node . readInteger ( ATT_WIDTH ) ; final int he... | Create an collision from its node . |
3,202 | public static void exports ( Xml root , Collision collision ) { Check . notNull ( root ) ; Check . notNull ( collision ) ; final Xml node = root . createChild ( NODE_COLLISION ) ; node . writeString ( ATT_NAME , collision . getName ( ) ) ; node . writeInteger ( ATT_OFFSETX , collision . getOffsetX ( ) ) ; node . writeI... | Create an XML node from a collision . |
3,203 | public Collision getCollision ( String name ) { if ( collisions . containsKey ( name ) ) { return collisions . get ( name ) ; } throw new LionEngineException ( ERROR_COLLISION_NOT_FOUND + name ) ; } | Get a collision data from its name . |
3,204 | private static Map < Circuit , Collection < TileRef > > getCircuits ( MapTile map ) { final MapTileGroup mapGroup = map . getFeature ( MapTileGroup . class ) ; final Map < Circuit , Collection < TileRef > > circuits = new HashMap < > ( ) ; final MapCircuitExtractor extractor = new MapCircuitExtractor ( map ) ; for ( in... | Get map tile circuits . |
3,205 | private static void checkCircuit ( Map < Circuit , Collection < TileRef > > circuits , MapCircuitExtractor extractor , MapTile map , Tile tile ) { final Circuit circuit = extractor . getCircuit ( tile ) ; if ( circuit != null ) { final TileRef ref = new TileRef ( tile ) ; getTiles ( circuits , circuit ) . add ( ref ) ;... | Check the tile circuit and add it to circuits collection if valid . |
3,206 | private static void checkTransitionGroups ( Map < Circuit , Collection < TileRef > > circuits , Circuit circuit , MapTile map , TileRef ref ) { final MapTileGroup mapGroup = map . getFeature ( MapTileGroup . class ) ; final MapTileTransition mapTransition = map . getFeature ( MapTileTransition . class ) ; final String ... | Check transitions groups and create compatible circuit on the fly . |
3,207 | private static Collection < TileRef > getTiles ( Map < Circuit , Collection < TileRef > > circuits , Circuit circuit ) { if ( ! circuits . containsKey ( circuit ) ) { circuits . put ( circuit , new HashSet < TileRef > ( ) ) ; } return circuits . get ( circuit ) ; } | Get the tiles for the circuit . Create empty list if new circuit . |
3,208 | private static Playback createPlayback ( Media media , Align alignment , int volume ) throws IOException { final AudioInputStream input = openStream ( media ) ; final SourceDataLine dataLine = getDataLine ( input ) ; dataLine . start ( ) ; updateAlignment ( dataLine , alignment ) ; updateVolume ( dataLine , volume ) ; ... | Play a sound . |
3,209 | private static AudioInputStream openStream ( Media media ) throws IOException { try { return AudioSystem . getAudioInputStream ( media . getInputStream ( ) ) ; } catch ( final UnsupportedAudioFileException exception ) { throw new IOException ( ERROR_PLAY_SOUND + media . getPath ( ) , exception ) ; } } | Open the audio stream and prepare it . |
3,210 | @ SuppressWarnings ( "resource" ) private static SourceDataLine getDataLine ( AudioInputStream input ) throws IOException { final AudioFormat format = input . getFormat ( ) ; try { final SourceDataLine dataLine ; if ( WavFormat . mixer != null ) { dataLine = AudioSystem . getSourceDataLine ( format , WavFormat . mixer ... | Get the audio data line . |
3,211 | private static void updateAlignment ( DataLine dataLine , Align alignment ) { if ( dataLine . isControlSupported ( Type . PAN ) ) { final FloatControl pan = ( FloatControl ) dataLine . getControl ( Type . PAN ) ; switch ( alignment ) { case CENTER : pan . setValue ( 0.0F ) ; break ; case RIGHT : pan . setValue ( 1.0F )... | Update the sound alignment . |
3,212 | private static void updateVolume ( DataLine dataLine , int volume ) { if ( dataLine . isControlSupported ( Type . MASTER_GAIN ) ) { final FloatControl gainControl = ( FloatControl ) dataLine . getControl ( Type . MASTER_GAIN ) ; final double gain = UtilMath . clamp ( volume / 100.0 , 0.0 , 100.0 ) ; final double dB = M... | Update the sound volume . |
3,213 | private static void readSound ( AudioInputStream input , SourceDataLine dataLine ) throws IOException { int read ; final byte [ ] buffer = new byte [ BUFFER ] ; while ( ( read = input . read ( buffer , 0 , buffer . length ) ) > 0 ) { dataLine . write ( buffer , 0 , read ) ; } } | Read the full sound and play it by buffer . |
3,214 | private static void close ( AudioInputStream input , DataLine dataLine ) throws IOException { dataLine . drain ( ) ; dataLine . flush ( ) ; dataLine . stop ( ) ; dataLine . close ( ) ; input . close ( ) ; } | Flush and close audio data and stream . |
3,215 | private void play ( Media media , Align alignment ) { try ( Playback playback = createPlayback ( media , alignment , volume ) ) { if ( opened . containsKey ( media ) ) { opened . get ( media ) . close ( ) ; } opened . put ( media , playback ) ; final AudioInputStream input = openStream ( media ) ; final SourceDataLine ... | Play sound . |
3,216 | public static ProducibleConfig imports ( Configurer configurer ) { Check . notNull ( configurer ) ; return imports ( configurer . getRoot ( ) ) ; } | Create the producible data from configurer . |
3,217 | public static ProducibleConfig imports ( Xml root ) { Check . notNull ( root ) ; final Xml node = root . getChild ( NODE_PRODUCIBLE ) ; final SizeConfig size = SizeConfig . imports ( root ) ; final int time = node . readInteger ( ATT_STEPS ) ; return new ProducibleConfig ( time , size . getWidth ( ) , size . getHeight ... | Create the producible data from node . |
3,218 | public static Xml exports ( ProducibleConfig config ) { Check . notNull ( config ) ; final Xml node = new Xml ( NODE_PRODUCIBLE ) ; node . writeInteger ( ATT_STEPS , config . getSteps ( ) ) ; return node ; } | Export the producible node from config . |
3,219 | private void fired ( Direction initial ) { for ( final LauncherListener listener : listenersLauncher ) { listener . notifyFired ( ) ; } for ( final LaunchableConfig launchableConfig : launchables ) { final Media media = Medias . create ( launchableConfig . getMedia ( ) ) ; final Featurable featurable = factory . create... | Called when fire is performed . |
3,220 | private void launch ( LaunchableConfig config , Direction initial , Featurable featurable , Launchable launchable ) { final double x = localizable . getX ( ) + config . getOffsetX ( ) + offsetX ; final double y = localizable . getY ( ) + config . getOffsetY ( ) + offsetY ; launchable . setLocation ( x , y ) ; final For... | Launch the launchable . |
3,221 | private Force computeVector ( Force vector ) { if ( target != null ) { return computeVector ( vector , target ) ; } vector . setDestination ( vector . getDirectionHorizontal ( ) , vector . getDirectionVertical ( ) ) ; return vector ; } | Compute the vector used for launch . |
3,222 | private Force computeVector ( Force vector , Localizable target ) { final double sx = localizable . getX ( ) ; final double sy = localizable . getY ( ) ; double dx = target . getX ( ) ; double dy = target . getY ( ) ; if ( target instanceof Transformable ) { final Transformable transformable = ( Transformable ) target ... | Compute the force vector depending of the target . |
3,223 | private int countTiles ( int widthInTile , int step , int s ) { int count = 0 ; for ( int tx = 0 ; tx < widthInTile ; tx ++ ) { for ( int ty = 0 ; ty < map . getInTileHeight ( ) ; ty ++ ) { if ( map . getTile ( tx + s * step , ty ) != null ) { count ++ ; } } } return count ; } | Count the active tiles . |
3,224 | private void saveTiles ( FileWriting file , int widthInTile , int step , int s ) throws IOException { for ( int tx = 0 ; tx < widthInTile ; tx ++ ) { for ( int ty = 0 ; ty < map . getInTileHeight ( ) ; ty ++ ) { final Tile tile = map . getTile ( tx + s * step , ty ) ; if ( tile != null ) { saveTile ( file , tile ) ; } ... | Save the active tiles . |
3,225 | private void appendMap ( MapTile other , int offsetX , int offsetY ) { for ( int v = 0 ; v < other . getInTileHeight ( ) ; v ++ ) { final int ty = offsetY + v ; for ( int h = 0 ; h < other . getInTileWidth ( ) ; h ++ ) { final int tx = offsetX + h ; final Tile tile = other . getTile ( h , v ) ; if ( tile != null ) { fi... | Append the map at specified offset . |
3,226 | public static boolean checkSha ( String value , String signature ) { Check . notNull ( signature ) ; return Arrays . equals ( getSha ( value ) . getBytes ( StandardCharsets . UTF_8 ) , signature . getBytes ( StandardCharsets . UTF_8 ) ) ; } | Compare a checksum with its supposed original value . |
3,227 | public static String getSha ( byte [ ] bytes ) { Check . notNull ( bytes ) ; final StringBuilder builder = new StringBuilder ( MAX_LENGTH ) ; for ( final byte b : SHA512 . digest ( bytes ) ) { builder . append ( 0xFF & b ) ; } return builder . toString ( ) ; } | Get the SHA - 256 signature of the input bytes . |
3,228 | public static String getSha ( String str ) { Check . notNull ( str ) ; return getSha ( str . getBytes ( StandardCharsets . UTF_8 ) ) ; } | Get the SHA - 256 signature of the input string . |
3,229 | private static MessageDigest create ( String algorithm ) { try { return MessageDigest . getInstance ( algorithm ) ; } catch ( final NoSuchAlgorithmException exception ) { throw new LionEngineException ( exception , ERROR_ALGORITHM + algorithm ) ; } } | Create digest . |
3,230 | public static Collection < CollisionCategory > imports ( Configurer configurer , MapTileCollision map ) { Check . notNull ( configurer ) ; Check . notNull ( map ) ; final Collection < Xml > children = configurer . getRoot ( ) . getChildren ( NODE_CATEGORY ) ; final Collection < CollisionCategory > categories = new Arra... | Create the categories data from nodes . |
3,231 | public static CollisionCategory imports ( Xml root , MapTileCollision map ) { Check . notNull ( root ) ; Check . notNull ( map ) ; final Collection < Xml > children = root . getChildren ( TileGroupsConfig . NODE_GROUP ) ; final Collection < CollisionGroup > groups = new ArrayList < > ( children . size ( ) ) ; for ( fin... | Create the category data from node . |
3,232 | public static void exports ( Xml root , CollisionCategory category ) { Check . notNull ( root ) ; Check . notNull ( category ) ; final Xml node = root . createChild ( NODE_CATEGORY ) ; node . writeString ( ATT_NAME , category . getName ( ) ) ; node . writeString ( ATT_AXIS , category . getAxis ( ) . name ( ) ) ; node .... | Export the collision category data as a node . |
3,233 | public void render ( Graphic g , Viewer viewer , Origin origin , Shape transformable , List < Collision > cacheColls , Map < Collision , Rectangle > cacheRect ) { if ( showCollision ) { final int size = cacheColls . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { final Collision collision = cacheColls . get ( i ) ; if... | Render collisions . |
3,234 | public static RasterData load ( Xml root , String color ) { final Xml node = root . getChild ( color ) ; final double force = node . readDouble ( ATT_FORCE ) ; final int amplitude = node . readInteger ( ATT_AMPLITUDE ) ; final int offset = node . readInteger ( ATT_OFFSET ) ; final int type = node . readInteger ( ATT_TY... | Load raster data from node . |
3,235 | private void initWindowed ( Resolution output ) { final Canvas canvas = new Canvas ( conf ) ; canvas . setBackground ( Color . BLACK ) ; canvas . setEnabled ( true ) ; canvas . setVisible ( true ) ; canvas . setIgnoreRepaint ( true ) ; frame . add ( canvas ) ; canvas . setPreferredSize ( new Dimension ( output . getWid... | Prepare windowed mode . |
3,236 | public final void setScreenSize ( int screenWidth , int screenHeight ) { this . screenWidth = screenWidth ; this . screenHeight = screenHeight ; final int w = ( int ) Math . ceil ( screenWidth / ( surface . getWidth ( ) * 0.6 * factH ) ) + 1 ; amplitude = ( int ) Math . ceil ( w / 2.0 ) + 1 ; } | Set the screen size . Used to know the parallax amplitude and the overall surface to render in order to fill the screen . |
3,237 | private void renderLine ( Graphic g , int numLine , int lineY ) { final int lineWidth = surface . getLineWidth ( numLine ) ; for ( int j = - amplitude ; j < amplitude ; j ++ ) { final int lx = ( int ) ( - offsetX + offsetX * j - x [ numLine ] - x2 [ numLine ] + numLine * ( 2.56 * factH ) * j ) ; if ( lx + lineWidth + d... | Render parallax line . |
3,238 | public void setMin ( int min ) { this . min = UtilMath . clamp ( min , 0 , Integer . MAX_VALUE ) ; max = UtilMath . clamp ( max , this . min , Integer . MAX_VALUE ) ; } | Set the minimum damage value . Max set to min value if over . |
3,239 | public void setDamages ( int min , int max ) { this . min = UtilMath . clamp ( min , 0 , Integer . MAX_VALUE ) ; this . max = UtilMath . clamp ( max , this . min , Integer . MAX_VALUE ) ; } | Set the maximum damage value . Max set to min value if over . |
3,240 | public static Document createDocument ( InputStream input ) throws IOException { Check . notNull ( input ) ; try { return getDocumentFactory ( ) . parse ( input ) ; } catch ( final SAXException exception ) { throw new IOException ( exception ) ; } } | Create a document from an input stream . |
3,241 | private static synchronized DocumentBuilder getDocumentFactory ( ) { if ( documentBuilder == null ) { final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; documentBuilderFactory . setIgnoringElementContentWhitespace ( true ) ; try { documentBuilderFactory . setFeature ( javax... | Get the document factory . |
3,242 | private static synchronized TransformerFactory getTransformerFactory ( ) { if ( transformerFactory == null ) { transformerFactory = TransformerFactory . newInstance ( ) ; transformerFactory . setAttribute ( javax . xml . XMLConstants . ACCESS_EXTERNAL_DTD , "" ) ; transformerFactory . setAttribute ( javax . xml . XMLCo... | Get the transformer factory . |
3,243 | public static byte [ ] intToByteArray ( int value ) { return new byte [ ] { ( byte ) ( value >>> Constant . BYTE_4 ) , ( byte ) ( value >>> Constant . BYTE_3 ) , ( byte ) ( value >>> Constant . BYTE_2 ) , ( byte ) value } ; } | Convert an integer to an array of byte . |
3,244 | public static boolean [ ] toBinary ( int number , int length ) { final boolean [ ] binary = new boolean [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { binary [ length - 1 - i ] = ( 1 << i & number ) != 0 ; } return binary ; } | Convert number to binary array representation . |
3,245 | public static int fromBinary ( boolean [ ] binary ) { Check . notNull ( binary ) ; int number = 0 ; for ( final boolean current : binary ) { number = number << 1 | boolToInt ( current ) ; } return number ; } | Convert binary array to number representation . |
3,246 | public static String toTitleCase ( String string ) { Check . notNull ( string ) ; final int length = string . length ( ) ; final StringBuilder result = new StringBuilder ( length ) ; for ( int i = 0 ; i < length ; i ++ ) { final String next = string . substring ( i , i + 1 ) ; if ( i == 0 ) { result . append ( next . t... | Convert a string to title case . |
3,247 | public static String toTitleCaseWord ( String string ) { Check . notNull ( string ) ; final String [ ] words = SPACE . split ( REPLACER . matcher ( string ) . replaceAll ( Constant . SPACE ) ) ; final StringBuilder title = new StringBuilder ( string . length ( ) ) ; for ( int i = 0 ; i < words . length ; i ++ ) { title... | Convert a string to a pure title case for each word replacing special characters by space . |
3,248 | public static Text createText ( String fontName , int size , TextStyle style ) { return factoryGraphic . createText ( fontName , size , style ) ; } | Crate a text . |
3,249 | public static ImageBuffer createImageBuffer ( int width , int height , ColorRgba transparency ) { return factoryGraphic . createImageBuffer ( width , height , transparency ) ; } | Create an image buffer . |
3,250 | public static ImageBuffer applyMask ( ImageBuffer imageBuffer , ColorRgba maskColor ) { return factoryGraphic . applyMask ( imageBuffer , maskColor ) ; } | Apply color mask to the image . |
3,251 | private static int getStyle ( TextStyle style ) { final int value ; if ( TextStyle . NORMAL == style ) { value = Font . TRUETYPE_FONT ; } else if ( TextStyle . BOLD == style ) { value = Font . BOLD ; } else if ( TextStyle . ITALIC == style ) { value = Font . ITALIC ; } else { throw new LionEngineException ( style ) ; }... | Get the style equivalence . |
3,252 | public void set ( double x1 , double y1 , double x2 , double y2 ) { this . x1 = x1 ; this . y1 = y1 ; this . x2 = x2 ; this . y2 = y2 ; } | Set the line coordinates . |
3,253 | public static Force imports ( Configurer configurer ) { Check . notNull ( configurer ) ; return imports ( configurer . getRoot ( ) ) ; } | Create the force data from setup . |
3,254 | public static Force imports ( Xml root ) { Check . notNull ( root ) ; final Xml node = root . getChild ( NODE_FORCE ) ; final Force force = new Force ( node . readDouble ( ATT_VX ) , node . readDouble ( ATT_VY ) ) ; force . setVelocity ( node . readDouble ( 0.0 , ATT_VELOCITY ) ) ; force . setSensibility ( node . readD... | Create the force data from node . |
3,255 | public static Xml exports ( Force force ) { Check . notNull ( force ) ; final Xml node = new Xml ( NODE_FORCE ) ; node . writeDouble ( ATT_VX , force . getDirectionHorizontal ( ) ) ; node . writeDouble ( ATT_VY , force . getDirectionVertical ( ) ) ; node . writeDouble ( ATT_VELOCITY , force . getVelocity ( ) ) ; node .... | Export the force node from data . |
3,256 | public static Collection < SpriteTiled > extract ( Collection < ImageBuffer > tiles , int horizontalTiles ) { final Surface surface = getSheetSize ( tiles , horizontalTiles ) ; final int horizontals = surface . getWidth ( ) ; final int verticals = surface . getHeight ( ) ; final int tilesPerSheet = Math . min ( tiles .... | Convert a set of tile to a set of tile sheets . |
3,257 | private static Surface getSheetSize ( Collection < ImageBuffer > tiles , int horizontalTiles ) { final int tilesNumber = tiles . size ( ) ; final int horizontals ; final int verticals ; if ( horizontalTiles > 0 ) { horizontals = horizontalTiles ; verticals = ( int ) Math . ceil ( tilesNumber / ( double ) horizontalTile... | Get the sheet size depending of the number of horizontal tiles and total number of tiles . |
3,258 | public boolean isVisible ( Tiled tiled ) { final int tx = tiled . getInTileX ( ) ; final int ty = tiled . getInTileY ( ) ; final int tw = tiled . getInTileWidth ( ) - 1 ; final int th = tiled . getInTileHeight ( ) - 1 ; for ( int ctx = tx ; ctx <= tx + tw ; ctx ++ ) { for ( int cty = ty ; cty <= ty + th ; cty ++ ) { if... | Check if the tile is currently visible . |
3,259 | public boolean isVisited ( int tx , int ty ) { return mapHidden . getTile ( tx , ty ) . getNumber ( ) == MapTileFog . NO_FOG ; } | In case of active fog of war check if tile has been discovered . |
3,260 | public boolean isFogged ( int tx , int ty ) { return mapFogged . getTile ( tx , ty ) . getNumber ( ) < MapTileFog . FOG ; } | In case of active fog of war check if tile is hidden by fog . |
3,261 | public void resetInterval ( Localizable localizable ) { final int intervalHorizontalOld = intervalHorizontal ; final int intervalVerticalOld = intervalVertical ; final double oldX = getX ( ) ; final double oldY = getY ( ) ; setIntervals ( 0 , 0 ) ; offset . setLocation ( 0.0 , 0.0 ) ; setLocation ( localizable . getX (... | Reset the camera interval to 0 by adapting its position . This will ensure camera centers its view to the localizable . |
3,262 | public void moveLocation ( double extrp , double vx , double vy ) { checkHorizontalLimit ( extrp , vx ) ; checkVerticalLimit ( extrp , vy ) ; } | Move camera by using specified vector . |
3,263 | public void setLocation ( double x , double y ) { final double dx = x - ( mover . getX ( ) + offset . getX ( ) ) ; final double dy = y - ( mover . getY ( ) + offset . getY ( ) ) ; moveLocation ( 1 , dx , dy ) ; } | Set the camera location . |
3,264 | public void drawFov ( Graphic g , int x , int y , int gridH , int gridV , Surface surface ) { final int h = x + ( int ) Math . floor ( ( getX ( ) + getViewX ( ) ) / gridH ) ; final int v = y + ( int ) - Math . floor ( ( getY ( ) + getHeight ( ) ) / gridV ) ; final int tileWidth = getWidth ( ) / gridH ; final int tileHe... | Draw the camera field of view according to a grid . |
3,265 | private void setLimits ( Surface surface , int gridH , int gridV ) { Check . notNull ( surface ) ; if ( gridH == 0 ) { limitRight = 0 ; } else { limitRight = Math . max ( 0 , surface . getWidth ( ) - UtilMath . getRounded ( width , gridH ) ) ; } if ( gridV == 0 ) { limitTop = 0 ; } else { limitTop = Math . max ( 0 , su... | Define the maximum view limit . |
3,266 | private void checkHorizontalLimit ( double extrp , double vx ) { if ( mover . getX ( ) >= limitLeft && mover . getX ( ) <= limitRight && limitLeft != Integer . MIN_VALUE && limitRight != Integer . MAX_VALUE ) { offset . moveLocation ( extrp , vx , 0 ) ; if ( offset . getX ( ) < - intervalHorizontal ) { offset . telepor... | Check horizontal limit on move . |
3,267 | private void checkVerticalLimit ( double extrp , double vy ) { if ( mover . getY ( ) >= limitBottom && mover . getY ( ) <= limitTop && limitBottom != Integer . MIN_VALUE && limitTop != Integer . MAX_VALUE ) { offset . moveLocation ( extrp , 0 , vy ) ; if ( offset . getY ( ) < - intervalVertical ) { offset . teleportY (... | Check vertical limit on move . |
3,268 | private void applyHorizontalLimit ( ) { if ( mover . getX ( ) < limitLeft && limitLeft != Integer . MIN_VALUE ) { mover . teleportX ( limitLeft ) ; } else if ( mover . getX ( ) > limitRight && limitRight != Integer . MAX_VALUE ) { mover . teleportX ( limitRight ) ; } } | Fix location inside horizontal limit . |
3,269 | private void applyVerticalLimit ( ) { if ( mover . getY ( ) < limitBottom && limitBottom != Integer . MIN_VALUE ) { mover . teleportY ( limitBottom ) ; } else if ( mover . getY ( ) > limitTop && limitTop != Integer . MAX_VALUE ) { mover . teleportY ( limitTop ) ; } } | Fix location inside vertical limit . |
3,270 | public void add ( Orientation orientation , String group ) { final Collection < String > groups = constraints . get ( orientation ) ; groups . add ( group ) ; } | Add the group constraint at the specified orientation . |
3,271 | public static Collection < TileGroup > imports ( Media groupsConfig ) { Check . notNull ( groupsConfig ) ; final Xml nodeGroups = new Xml ( groupsConfig ) ; final Collection < Xml > children = nodeGroups . getChildren ( NODE_GROUP ) ; final Collection < TileGroup > groups = new ArrayList < > ( children . size ( ) ) ; f... | Import the group data from configuration . |
3,272 | public static void exports ( Media groupsConfig , Iterable < TileGroup > groups ) { Check . notNull ( groupsConfig ) ; Check . notNull ( groups ) ; final Xml nodeGroups = new Xml ( NODE_GROUPS ) ; nodeGroups . writeString ( Constant . XML_HEADER , Constant . ENGINE_WEBSITE ) ; for ( final TileGroup group : groups ) { e... | Export groups to configuration file . |
3,273 | private static TileGroup importGroup ( Xml nodeGroup ) { final Collection < Xml > children = nodeGroup . getChildren ( TileConfig . NODE_TILE ) ; final Collection < TileRef > tiles = new ArrayList < > ( children . size ( ) ) ; for ( final Xml nodeTileRef : children ) { final TileRef tileRef = TileConfig . imports ( nod... | Import the group from its node . |
3,274 | private static void exportGroup ( Xml nodeGroups , TileGroup group ) { final Xml nodeGroup = nodeGroups . createChild ( NODE_GROUP ) ; nodeGroup . writeString ( ATT_GROUP_NAME , group . getName ( ) ) ; nodeGroup . writeString ( ATT_GROUP_TYPE , group . getType ( ) . name ( ) ) ; for ( final TileRef tileRef : group . ge... | Export the group data as a node . |
3,275 | public final void setScreenWidth ( int screenWidth ) { final int wi = ( int ) Math . ceil ( screenWidth / ( double ) sprite . getWidth ( ) ) + 1 ; w = wi ; } | Set the screen width . Used to know how much clouds are needed in order to fill the screen . |
3,276 | private void kick ( ) { if ( ! connected ) { return ; } messagesIn . clear ( ) ; messagesOut . clear ( ) ; try { out . close ( ) ; } catch ( final IOException exception ) { Verbose . exception ( exception , "Error on closing output" ) ; } try { in . close ( ) ; } catch ( final IOException exception ) { Verbose . except... | Terminate connection . |
3,277 | private String readString ( ) throws IOException { final int size = in . readByte ( ) ; if ( size > 0 ) { final byte [ ] name = new byte [ size ] ; if ( in . read ( name ) != - 1 ) { return new String ( name , NetworkMessage . CHARSET ) ; } } return null ; } | Get the name value read from the stream . |
3,278 | private void updateMessage ( byte messageSystemId ) throws IOException { switch ( messageSystemId ) { case NetworkMessageSystemId . CONNECTING : updateConnecting ( ) ; break ; case NetworkMessageSystemId . CONNECTED : updateConnected ( ) ; break ; case NetworkMessageSystemId . PING : ping = ( int ) pingTimer . elapsed ... | Update the message from its id . |
3,279 | private void updateConnecting ( ) throws IOException { if ( clientId == - 1 ) { clientId = in . readByte ( ) ; out . writeByte ( NetworkMessageSystemId . CONNECTING ) ; out . writeByte ( clientId ) ; final byte [ ] data = clientName . getBytes ( NetworkMessage . CHARSET ) ; out . writeByte ( data . length ) ; out . wri... | Update the connecting case . |
3,280 | private void updateConnected ( ) throws IOException { byte cid = in . readByte ( ) ; if ( cid != clientId ) { return ; } for ( final ConnectionListener listener : listeners ) { listener . notifyConnectionEstablished ( Byte . valueOf ( clientId ) , clientName ) ; } final int clientsNumber = in . readByte ( ) ; for ( int... | Update the connected case . |
3,281 | private void updateOtherClientConnected ( ) throws IOException { final byte cid = in . readByte ( ) ; final String cname = readString ( ) ; for ( final ConnectionListener listener : listeners ) { listener . notifyClientConnected ( Byte . valueOf ( cid ) , cname ) ; } } | Update the other client connected case . |
3,282 | private void updateOtherClientDisconnected ( ) throws IOException { final byte cid = in . readByte ( ) ; final String cname = readString ( ) ; for ( final ConnectionListener listener : listeners ) { listener . notifyClientDisconnected ( Byte . valueOf ( cid ) , cname ) ; } } | Update the other client disconnected case . |
3,283 | private void sendMessage ( NetworkMessage message ) { try ( ByteArrayOutputStream encode = message . encode ( ) ) { final byte [ ] encoded = encode . toByteArray ( ) ; out . writeByte ( NetworkMessageSystemId . USER_MESSAGE ) ; out . writeByte ( message . getClientId ( ) ) ; out . writeByte ( message . getClientDestId ... | Send message over the network . |
3,284 | public static List < File > getDirectories ( File path ) { Check . notNull ( path ) ; return Optional . ofNullable ( path . listFiles ( ) ) . map ( files -> Arrays . asList ( files ) . stream ( ) . filter ( File :: isDirectory ) . collect ( Collectors . toList ( ) ) ) . orElseGet ( Collections :: emptyList ) ; } | Get all directories existing in the path . |
3,285 | public static String getPathSeparator ( String separator , String ... path ) { Check . notNull ( separator ) ; Check . notNull ( path ) ; final StringBuilder fullPath = new StringBuilder ( path . length ) ; for ( int i = 0 ; i < path . length ; i ++ ) { if ( i == path . length - 1 ) { fullPath . append ( path [ i ] ) ;... | Construct a usable path using a list of string automatically separated by the portable separator . |
3,286 | public static CollisionConstraint imports ( Xml node ) { Check . notNull ( node ) ; final CollisionConstraint constraint = new CollisionConstraint ( ) ; if ( node . hasChild ( NODE_CONSTRAINT ) ) { for ( final Xml current : node . getChildren ( NODE_CONSTRAINT ) ) { final Orientation orientation = Orientation . valueOf... | Create the collision constraint data from node . |
3,287 | public static void exports ( Xml root , CollisionConstraint constraint ) { Check . notNull ( root ) ; Check . notNull ( constraint ) ; for ( final Entry < Orientation , Collection < String > > entry : constraint . getConstraints ( ) . entrySet ( ) ) { final Orientation orientation = entry . getKey ( ) ; for ( final Str... | Export the collision constraint as a node . |
3,288 | private void remove ( Integer layer , Refreshable refreshable ) { final Collection < Refreshable > refreshables = getLayer ( layer ) ; refreshables . remove ( refreshable ) ; if ( refreshables . isEmpty ( ) ) { indexs . remove ( layer ) ; } } | Remove refreshable and its layer . |
3,289 | public static CollisionFormulaConfig imports ( Media config ) { final Xml root = new Xml ( config ) ; final Map < String , CollisionFormula > collisions = new HashMap < > ( 0 ) ; for ( final Xml node : root . getChildren ( NODE_FORMULA ) ) { final String name = node . readString ( ATT_NAME ) ; final CollisionFormula co... | Create the formula data from node . |
3,290 | public static void exports ( Xml root , CollisionFormula formula ) { Check . notNull ( root ) ; Check . notNull ( formula ) ; final Xml node = root . createChild ( NODE_FORMULA ) ; node . writeString ( ATT_NAME , formula . getName ( ) ) ; CollisionRangeConfig . exports ( node , formula . getRange ( ) ) ; CollisionFunct... | Export the current formula data to the formula node . |
3,291 | public static CollisionFormula createCollision ( Xml node ) { Check . notNull ( node ) ; final String name = node . readString ( ATT_NAME ) ; final CollisionRange range = CollisionRangeConfig . imports ( node . getChild ( CollisionRangeConfig . NODE_RANGE ) ) ; final CollisionFunction function = CollisionFunctionConfig... | Create a collision formula from its node . |
3,292 | public static void remove ( Xml root , String formula ) { Check . notNull ( root ) ; Check . notNull ( formula ) ; for ( final Xml node : root . getChildren ( NODE_FORMULA ) ) { if ( node . readString ( ATT_NAME ) . equals ( formula ) ) { root . removeChild ( node ) ; } } } | Remove the formula node . |
3,293 | public static boolean has ( Xml root , String formula ) { Check . notNull ( root ) ; Check . notNull ( formula ) ; for ( final Xml node : root . getChildren ( NODE_FORMULA ) ) { if ( node . readString ( ATT_NAME ) . equals ( formula ) ) { return true ; } } return false ; } | Check if node has formula node . |
3,294 | public double getInputValue ( Axis input , double x , double y ) { final double v ; switch ( input ) { case X : v = Math . floor ( x - tile . getX ( ) ) ; break ; case Y : v = Math . floor ( y - tile . getY ( ) ) ; break ; default : throw new LionEngineException ( input ) ; } return v ; } | Get the input value relative to tile . |
3,295 | private Double getCollisionX ( CollisionRange range , CollisionFunction function , double x , double y , int offsetX ) { final double yOnTile = getInputValue ( Axis . Y , x , y ) ; if ( UtilMath . isBetween ( yOnTile , range . getMinY ( ) , range . getMaxY ( ) ) ) { final double xOnTile = getInputValue ( Axis . X , x ,... | Get the horizontal collision location between the tile and the current location . |
3,296 | int [ ] getScaledData ( int [ ] srcImage ) { final int [ ] dstImage = new int [ srcImage . length * SCALE * SCALE ] ; for ( int y = 0 ; y < height ; y ++ ) { for ( int x = 0 ; x < width ; x ++ ) { process ( srcImage , dstImage , x , y ) ; } } return dstImage ; } | Get the scaled data . |
3,297 | private void setDestPixel ( int [ ] dstImage , int x , int y , int p ) { dstImage [ x + y * width * SCALE ] = p ; } | Set destination pixel . |
3,298 | private int getSourcePixel ( int [ ] srcImage , int x , int y ) { int x1 = Math . max ( 0 , x ) ; x1 = Math . min ( width - 1 , x1 ) ; int y1 = Math . max ( 0 , y ) ; y1 = Math . min ( height - 1 , y1 ) ; return srcImage [ x1 + y1 * width ] ; } | Get pixel source . |
3,299 | private void process ( int [ ] srcImage , int [ ] dstImage , int x , int y ) { final int b = getSourcePixel ( srcImage , x , y - 1 ) ; final int d = getSourcePixel ( srcImage , x - 1 , y ) ; final int e = getSourcePixel ( srcImage , x , y ) ; final int f = getSourcePixel ( srcImage , x + 1 , y ) ; final int h = getSour... | Process filter . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.