示例#1
0
void DummySprites()
{
	setBrightness(0);
	setSpriteData(0, TEMP_SPRITE1_PAL_ID, 2, &Link, &testgfx, &testgfx_end, &testpal);
	dmaCopyCGram(&spritepal, 128+(1<<4), (16<<1)); //16 colors per palette, 2 bytes per color.
	oamInitGfxSet(Link.gfx, Link.gfxSize, Link.pal, Link.palId, SPRITE1_ADDR_OFFSET + (Link.gfxId), OBJ_SIZE16);
	
	u8 i, x = 0, y = 0;
	for(i = 0; i < 129; ++i){
		x=(i-1)&0xF;
		if(((i-1)&0xF) == 0){
			++y;
		}
		//Link.priority = (i-1)&3;
		Link.gfxId = (i-1);
		Link.palId = y&x&1;//;(i-1)&1;
		Link.x = (x<<4);
		Link.y = (y<<4)+32;//((i<<2)+0x10)&0xFF;
		loadSpriteData(&Link);
		//WaitForVBlank(); //Why was this necessary? Seemed to only slow things down
		//UpdateSprite(i, (x<<4)&0xFF, (y<<4)&0xFF);
	}
	i = 0;

	/*setSpriteData(1, 3, &Link, &spritegfx, &spritegfx_end, &testpal, 0);
	Link.x = 32;
	Link.y = 64;
	loadSpriteData(&Link, OBJ_SIZE16);
	WaitForVBlank();

	setSpriteData(2, 3, &Link, &testgfx, &testgfx_end, &spritepal, 1);
	Link.x = 32;
	Link.y = 96;
	loadSpriteData(&Link, OBJ_SIZE16);
	WaitForVBlank();*/
}
示例#2
0
        Player () {
            PlayerNumber = totalPlayers;
            Sprite = loadSpriteData("Player " + intToString(PlayerNumber + 1));
            //Get Global width, seperate to rotation
            CharacterWidth = Sprite.getGlobalBounds().width;
            nameSpacing = 30;
            healthBarSpacing = nameSpacing + 15;

            Sprite.setOrigin(Sprite.getGlobalBounds().width/2, Sprite.getGlobalBounds().height/2);
            Sprite.setPosition((App.getSize().x/2) - (Sprite.getGlobalBounds().width/2), (App.getSize().y/2) - (Sprite.getGlobalBounds().height/2));

            //PlayerName.setFont(sf::Font::getDefaultFont());
            PlayerName.setCharacterSize(15);
            PlayerName.setString("Player: " + intToString(PlayerNumber + 1));
            PlayerName.setOrigin(PlayerName.getGlobalBounds().width/2, PlayerName.getGlobalBounds().height/2);
            PlayerName.setPosition(Sprite.getPosition().x, Sprite.getPosition().y + nameSpacing);

            NameOutline.setSize(sf::Vector2f(PlayerName.getGlobalBounds().width, PlayerName.getGlobalBounds().height));
            NameOutline.setOutlineThickness(2);
            NameOutline.setFillColor(sf::Color(0, 0, 0, 120));
            NameOutline.setOutlineColor(sf::Color::Black);
            NameOutline.setOrigin(NameOutline.getGlobalBounds().width/2, NameOutline.getGlobalBounds().height/2);
            NameOutline.setPosition(Sprite.getPosition().x + 1.5, Sprite.getPosition().y + nameSpacing + 4);

            MaxHealth = Health = 100;
            HealthBarSize = 50;

            HealthBarRed.setSize(sf::Vector2f(HealthBarSize, 5));
            HealthBarRed.setOutlineThickness(1);
            HealthBarRed.setFillColor(sf::Color::Red);
            HealthBarRed.setOutlineColor(sf::Color::Black);
            HealthBarRed.setPosition(Sprite.getPosition().x - (CharacterWidth/2) - 5, Sprite.getPosition().y + healthBarSpacing);

            HealthBarGreen.setSize(sf::Vector2f(HealthBarSize, 5));
            HealthBarGreen.setOutlineThickness(1);
            HealthBarGreen.setFillColor(sf::Color::Green);
            HealthBarGreen.setOutlineColor(sf::Color::Black);
            HealthBarGreen.setPosition(Sprite.getPosition().x - (CharacterWidth/2) - 5, Sprite.getPosition().y + healthBarSpacing);

            if (controllerConnected) {
                ControlScheme = ControlSchemes::Joystick;
                Key k;
                k.InputType = Input::JoystickMovedNeg;
                k.KeyCode = sf::Joystick::Axis::Y;
                Bindings["Up"] = k;

                k.InputType = Input::JoystickMovedPos;
                k.KeyCode = sf::Joystick::Axis::Y;
                Bindings["Down"] = k;

                k.InputType = Input::JoystickMovedNeg;
                k.KeyCode = sf::Joystick::Axis::X;
                Bindings["Left"] = k;

                k.InputType = Input::JoystickMovedPos;
                k.KeyCode = sf::Joystick::Axis::X;
                Bindings["Right"] = k;
                } else {
                    ControlScheme = ControlSchemes::KeyboardMouse;
                    Key k;
                    k.InputType = Input::KeyboardInput;
                    k.KeyCode = sf::Keyboard::W;
                    Bindings["Up"] = k;

                    k.InputType = Input::KeyboardInput;
                    k.KeyCode = sf::Keyboard::S;
                    Bindings["Down"] = k;

                    k.InputType = Input::KeyboardInput;
                    k.KeyCode = sf::Keyboard::A;
                    Bindings["Left"] = k;

                    k.InputType = Input::KeyboardInput;
                    k.KeyCode = sf::Keyboard::D;
                    Bindings["Right"] = k;
                    }

            totalPlayers++;
            }