Esempio n. 1
0
File: game.c Progetto: ljg6/MyGame2D
void init_lvl1Graphics()
{
	camera = vec2d(0,0);
	floor = loadSprite("images/ground.png",1600,600,1);
    backTrees = loadSprite("images/back_treeline.png",1600,600,1);
    frontTrees = loadSprite("images/front_treeline.png",1600,600,1);
}
Esempio n. 2
0
void GameWidget::setPieces(PiecesType type)
{
	QString prefix;

	switch (type) {
	case Pieces_Smiles:
		prefix = "block-a";
		loadSprite(Sprite_Cleared, "cleared-a.bmp");
		break;
	case Pieces_Symbols:
		prefix = "block-b";
		loadSprite(Sprite_Cleared, "cleared-b.bmp");
		break;
	case Pieces_Icons:
		prefix = "block-c";
		loadSprite(Sprite_Cleared, "cleared-c.bmp");
	}

	for (int i = 0; i < num_blocks; ++i) {
		QString n;
		n.setNum(i + 1);
		loadSprite((Sprite)(Sprite_Block1 + i), prefix + n + ".bmp");
	}
	QPixmap pm(32, 32);
	for (int i = 0; i < num_blocks; ++i) {
		QPainter p;
		p.begin(&pm);
		p.drawPixmap(0, 0, sprites[Sprite_Block1 + i]);
		p.drawPixmap(0, 0, sprites[Sprite_Broken]);
		p.end();
		sprites[Sprite_Broken1 + i] = pm;
	}

	if (in_game) repaintChilds();
}
Esempio n. 3
0
File: game.c Progetto: ljg6/MyGame2D
void init_lvl2Graphics()
{
	camera = vec2d(0,0);
	levelTwoFloor = loadSprite("images/level2_ground.png",1600,600,1);
    levelTwoBackTrees = loadSprite("images/level2_back_treeline.png",1600,600,1);
    levelTwoFrontTrees = loadSprite("images/level2_front_treeline.png",1600,600,1);
    moonBack = loadSprite("images/moon.png",800,600,1);
}
Esempio n. 4
0
File: game.c Progetto: ljg6/MyGame2D
void init_UI()
{
	health_title = entity_new();
	health_title->sprite = loadSprite("images/healthbartitle.png",216,36,1);
    health_title->position.x = 0;
    health_title->position.y = 0;
	bulletFont = TTF_OpenFont("fonts/FantasqueSansMono-Regular.ttf",12);
	healthFont = TTF_OpenFont("fonts/FantasqueSansMono-Regular.ttf",14);
    health_bar  = loadSprite("images/healthbar.png",352,32,1);

	healthTrack.x = 176;
	healthTrack.y = 60;
	sprintf(healthText,"%3d%%",playerData.health);
	health_Surface = TTF_RenderText_Solid(healthFont,healthText,healthColor);
	health_Texture = SDL_CreateTextureFromSurface(gt_graphics_get_active_renderer(),health_Surface);
	healthTrack.w = health_Surface->w;
	healthTrack.h = health_Surface->h;
	SDL_FreeSurface(health_Surface);
	SDL_RenderCopy(gt_graphics_get_active_renderer(),health_Texture,NULL,&healthTrack);
	

	bulletTarget.x = 700;
    bulletTarget.y = 100;
	sprintf(bulletText,"Bullets: %d",playerData.bullets);
	bullet_Surface = TTF_RenderText_Solid(bulletFont,bulletText,projectileColor);
	bullet_Texture = SDL_CreateTextureFromSurface(gt_graphics_get_active_renderer(),bullet_Surface);
	bulletTarget.w = bullet_Surface->w;
	bulletTarget.h = bullet_Surface->h;
	SDL_FreeSurface(bullet_Surface);
	SDL_RenderCopy(gt_graphics_get_active_renderer(),bullet_Texture,NULL,&bulletTarget);
	

	bulletTarget.x = 700;
    bulletTarget.y = 125;
	sprintf(bulletText,"shells: %d",playerData.shells);
	bullet_Surface = TTF_RenderText_Solid(bulletFont,bulletText,projectileColor);
	bullet_Texture = SDL_CreateTextureFromSurface(gt_graphics_get_active_renderer(),bullet_Surface);
	bulletTarget.w = bullet_Surface->w;
	bulletTarget.h = bullet_Surface->h;
	SDL_FreeSurface(bullet_Surface);
	SDL_RenderCopy(gt_graphics_get_active_renderer(),bullet_Texture,NULL,&bulletTarget);
	

	bulletTarget.x = 700;
    bulletTarget.y = 150;
	sprintf(bulletText,"Rounds: %d",playerData.rounds);
	bullet_Surface = TTF_RenderText_Solid(bulletFont,bulletText,projectileColor);
	bullet_Texture = SDL_CreateTextureFromSurface(gt_graphics_get_active_renderer(),bullet_Surface);
	bulletTarget.w = bullet_Surface->w;
	bulletTarget.h = bullet_Surface->h;
	SDL_FreeSurface(bullet_Surface);
	SDL_RenderCopy(gt_graphics_get_active_renderer(),bullet_Texture,NULL,&bulletTarget);
	
}
Esempio n. 5
0
MSprite::MSprite(Common::SeekableReadStream *source, const Common::Array<RGB6> &palette,
		const Common::Rect &bounds): MSurface(), _transparencyIndex(TRANSPARENT_COLOR_INDEX),
	  _offset(Common::Point(bounds.left, bounds.top)) {
	// Load the sprite data
	create(bounds.width(), bounds.height());
	loadSprite(source, palette);
}
Esempio n. 6
0
Drawable::Drawable(std::string filename) {

	std::vector<std::string> filenames;
	filenames.push_back(filename);
	sprites = loadSprite( filenames );
	currentSprite = 0;
}
Esempio n. 7
0
void SpriteDef::includeSprite(XmlNodePtr includeNode)
{
    std::string filename = XML::getProperty(includeNode, "file", "");

    if (filename.empty())
        return;
    filename = paths.getStringValue("sprites") + filename;

    if (mProcessedFiles.find(filename) != mProcessedFiles.end())
    {
        logger->log("Error, Tried to include %s which already is included.",
            filename.c_str());
        return;
    }
    mProcessedFiles.insert(filename);

    XML::Document doc(filename);
    XmlNodePtr rootNode = doc.rootNode();

    if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
    {
        logger->log("Error, no sprite root node in %s", filename.c_str());
        return;
    }

    loadSprite(rootNode, 0);
}
Esempio n. 8
0
File: main.cpp Progetto: jhasse/jngl
void load(const std::string& filename) {
    if (filename.length() >= 4 && filename.substr(filename.length() - 4) == ".ogg") {
        loadSound(filename);
    } else {
        loadSprite(filename);
    }
}
Esempio n. 9
0
void VHParticlesRender::initParticlesRender(){


		  // Create the CUDPP radix sort
    CUDPPConfiguration sortConfig;
    sortConfig.algorithm = CUDPP_SORT_RADIX;
    sortConfig.datatype = CUDPP_FLOAT;
    sortConfig.op = CUDPP_ADD;
    sortConfig.options = CUDPP_OPTION_KEY_VALUE_PAIRS;
    cudppPlan(&m_sortHandle, sortConfig, pSys->nParts, 1, 0);

	//-----shaders

	/*char currentPath[_MAX_PATH];
	getcwd(currentPath, _MAX_PATH);
	printf("Path : %s", currentPath);*/

	simpleSpriteProg = new GLSLProgram("sprite.vs", "sprite.gs", "simpleSprite.ps");
	shadowedSpriteProg = new GLSLProgram("sprite.vs", "sprite.gs", "shadowedSprite.ps");
	shadowMapSpriteProg = new GLSLProgram("sprite.vs", "sprite.gs", "ShadowMapSprite.ps");
	displayTexProg = new GLSLProgram("passThru.vs", "texture2D.ps");
	blurProg = new GLSLProgram("passThru.vs", "blur.ps");

	if(spritePath)
		loadSprite(spritePath);

	initFbos(width, height, true);
}
Esempio n. 10
0
SsScene2901LocationButtonLight::SsScene2901LocationButtonLight(NeverhoodEngine *vm, int which, uint index)
	: StaticSprite(vm, 900), _index(index) {

	loadSprite(kSsScene2901LocationButtonLightFileHashes1[which * 6 + index], kSLFDefDrawOffset | kSLFDefPosition, 900);
	setVisible(false);
	loadSound(0, kSsScene2901LocationButtonLightFileHashes2[_index]);
}
Esempio n. 11
0
File: game.c Progetto: ljg6/MyGame2D
void fire_Heavy_Machinegun()
{
	Entity *round;
	if(playerData.rounds > 0&& playerData.shotTimer <= 0)
	{
		playerData.rounds--;
		if(playerData.shotCounter >= 80)
		{
			playerData.shotCounter = 0;
			playerData.shotTimer = 700;
		}else{
			playerData.shotCounter++;
			playerData.shotTimer = 70;
		}
		round = entity_new();
		round->position.x = player->position.x + 45;
		round->position.y = player->position.y + 42;
		round->sprite = loadSprite("images/round.png",20,10,1);
		round->velocity.x = 35;
		if(player->facingLeft == 1)
		{
			round->velocity.x =-35;
		}
	}
}
Esempio n. 12
0
void SpriteCache::precache(int index)
{
  if ((index < 0) || (index >= elements))
    return;

  int sprSize = 0;

  if (images[index] == NULL) {
    sprSize = loadSprite(index);
  }
  else if (offsets[index] != SPRITE_LOCKED) {
    sprSize = sizes[index];
  }

  // make sure locked sprites can't fill the cache
  maxCacheSize += sprSize;
  lockedSize += sprSize;

  offsets[index] = SPRITE_LOCKED;

#ifdef DEBUG_SPRITECACHE
  char msgg[100];
  sprintf(msgg, "Precached %d", index);
  write_log(msgg);
#endif
}
Esempio n. 13
0
File: game.c Progetto: ljg6/MyGame2D
int pause_menu()
{
  static int i = 0;
  SDL_Renderer *render;
  render = gt_graphics_get_active_renderer();
  SDL_RenderClear(gt_graphics_get_active_renderer());
  ResetBuffer();
  mainScreen = loadSprite("images/pause_screen.png",800,600,1);
  selection = loadSprite("images/selection.png",149,53,1);
  if(i == 0)
	{
		drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
		drawSprite(selection,0,vec2d(311,294),vec2d(1,1),0,gt_graphics_get_active_renderer());
  }else if(i ==1)
  {
	  drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  drawSprite(selection,0,vec2d(311,377),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  
  }
  NextFrame();
  SDL_PumpEvents();
  keys = SDL_GetKeyboardState(NULL);
  if(keys[SDL_SCANCODE_ESCAPE])
    {
        done = 1;
    }
  if(keys[SDL_SCANCODE_DOWN])
    {
	  i = 1;
	}
  if(keys[SDL_SCANCODE_UP])
  {
	  i = 0;
  }
  if(keys[SDL_SCANCODE_RETURN])
  {
	  if(i == 0)
	  {
		  gameState = 1;
	  }
	  else
	  {
		  done = 1;
	  }
  }	  
   return 1;
}
Esempio n. 14
0
void SpriteComponent::draw(Renderer* renderer, float x, float y, float z_offset,
		int subspr, std::string spr_label,int depth) {
	resourceHandler=renderer->rh;
	loadSprite(this->resourceHandler,currentPalette);
	assert(subspr >= 0);
	subsprite sub = spr->getSubsprite(spr_label,subspr);
	renderer->addPainter(Painter::makeRaster(sub.img,x - sub.x_orig, y - sub.y_orig - z_offset),depth,y);
}
Esempio n. 15
0
DiskplayerPlayButton::DiskplayerPlayButton(NeverhoodEngine *vm, DiskplayerScene *diskplayerScene)
	: StaticSprite(vm, 1400), _diskplayerScene(diskplayerScene), _isPlaying(false) {
	
	loadSprite(0x24A4A664, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400);
	setVisible(false);
	loadSound(0, 0x44043000);
	loadSound(1, 0x44045000);
	SetMessageHandler(&DiskplayerPlayButton::handleMessage);
}
Esempio n. 16
0
SsScene3011Button::SsScene3011Button(NeverhoodEngine *vm, Scene *parentScene, bool flag)
	: StaticSprite(vm, 1400), _parentScene(parentScene), _countdown(0) {

	loadSprite(flag ? 0x11282020 : 0x994D0433, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400);
	setVisible(false);
	loadSound(0, 0x44061000);
	SetUpdateHandler(&SsScene3011Button::update);
	SetMessageHandler(&SsScene3011Button::handleMessage);
}
Esempio n. 17
0
void LayerBuild(LAYER *dest_layer, IMAGE *img, int width, int height, int source_y, int draw_y)
{
    dest_layer->height = height;
    dest_layer->width = width;
    dest_layer->x = 0;
    dest_layer->y = draw_y;
    
    loadSprite(&dest_layer->spr, img, 0, source_y, width, height);
}
Esempio n. 18
0
SsScene1105OpenButton::SsScene1105OpenButton(NeverhoodEngine *vm, Scene *parentScene)
	: StaticSprite(vm, 900), _parentScene(parentScene), _countdown(0), _isClicked(false) {

	loadSprite(0x8228A46C, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400);
	setVisible(false);
	loadSound(0, 0x44045140);
	SetUpdateHandler(&SsScene1105OpenButton::update);
	SetMessageHandler(&SsScene1105OpenButton::handleMessage);
}
Esempio n. 19
0
SsScene3009FireCannonButton::SsScene3009FireCannonButton(NeverhoodEngine *vm, Scene3009 *parentScene)
	: StaticSprite(vm, 1400), _parentScene(parentScene), _isClicked(false) {

	loadSprite(0x120B24B0, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400);
	setVisible(false);
	SetUpdateHandler(&SsScene3009FireCannonButton::update);
	SetMessageHandler(&SsScene3009FireCannonButton::handleMessage);
	loadSound(0, 0x3901B44F);
}
Esempio n. 20
0
void SsCommonFloorButton::update() {
	if (_countdown != 0 && (--_countdown == 0)) {
		sendMessage(_parentScene, 0x1022, 1010);
		if (_fileHash1)
			loadSprite(_fileHash1, kSLFDefDrawOffset | kSLFDefPosition);
		else
			setVisible(false);
	}
}	
Esempio n. 21
0
Building::Building(const std::string &className,
    const std::string &displayName,
    const sf::IntRect &spriteRect,
    int size,
    ImageManager *imgMgr) :
  Entity(className, displayName, spriteRect, size)
{
  loadSprite(imgMgr, "buildings");
}
Esempio n. 22
0
block SpriteCache::operator [] (int index)
{
  // invalid sprite slot
  if ((index < 0) || (index >= elements))
    return NULL;

  // Dynamically added sprite, don't put it on the sprite list
  if ((images[index] != NULL) && 
      ((offsets[index] == 0) || ((flags[index] & SPRCACHEFLAG_DOESNOTEXIST) != 0)))
    return images[index];

  // if sprite exists in file but is not in mem, load it
  if ((images[index] == NULL) && (offsets[index] > 0))
    loadSprite(index);

  // Locked sprite, eg. mouse cursor, that shouldn't be discarded
  if (offsets[index] == SPRITE_LOCKED)
    return images[index];

  if (liststart < 0) {
    liststart = index;
    listend = index;
    mrulist[index] = END_OF_LIST;
    mrubacklink[index] = START_OF_LIST;
  } 
  else if (listend != index) {
    // this is the oldest element being bumped to newest, so update start link
    if (index == liststart) {
      liststart = mrulist[index];
      mrubacklink[liststart] = START_OF_LIST;
    }
    // already in list, link previous to next
    else if (mrulist[index] > 0) {
      mrulist[mrubacklink[index]] = mrulist[index];
      mrubacklink[mrulist[index]] = mrubacklink[index];
    }

    // set this as the newest element in the list
    mrulist[index] = END_OF_LIST;
    mrulist[listend] = index;
    mrubacklink[index] = listend;
    listend = index;

/*    char bbb[50];   // Print out the MRU list
    sprintf(bbb, "Used %d, list is:", index);
    write_log(bbb);

    for (int i = liststart; 1; i = mrulist[i]) {
      
      sprintf(bbb, "%d", i);
      write_log(bbb);
      if (i == listend) break;
    }*/
  }

  return images[index];
}
Esempio n. 23
0
/**
load up all of the sprites that we will use in the program. Add more sprites as needed here:
*/
void loadAllSprites()
{
	loadSprite(PLAYERSPRITE, "data/world/player/playerDown.gif");
	loadSprite(PLAYERDOWNWALK, "data/world/player/playerDownWalk1.gif");
	loadSprite(PLAYERUP, "data/world/player/playerUp.gif");
	loadSprite(PLAYERUPWALK, "data/world/player/playerUpWalk1.gif");
	loadSprite(PLAYERRIGHT, "data/world/player/playerRight.gif");
	loadSprite(PLAYERRIGHTWALK, "data/world/player/playerRightWalk.gif");
	loadSprite(PLAYERLEFT, "data/world/player/playerLeft.gif");
	loadSprite(PLAYERLEFTWALK, "data/world/player/playerLeftWalk.gif");
}
Esempio n. 24
0
File: game.c Progetto: ljg6/MyGame2D
/**
* @brief Fires the players shotgun.
*/
void fire_Shotgun()
{
	Entity *shellHigh;
	Entity *shellLow;
	Entity *shellMid;
	if(playerData.shells > 0 && playerData.shotTimer <= 0)
	{
		playerData.shells--;
		playerData.shotTimer = 1400;
		shellHigh = entity_new();
		shellLow = entity_new();
		shellMid = entity_new();


		shellMid->position.x = player->position.x + 45;
		shellMid->position.y = player->position.y + 42;
		shellMid->sprite = loadSprite("images/shell.png",20,10,1);
		shellMid->velocity.x = 30;
		if(player->facingLeft == 1)
		{
			shellMid->velocity.x =-30;
		}

		shellHigh->position.x = player->position.x + 45;
		shellHigh->position.y = player->position.y + 42;
		shellHigh->sprite = loadSprite("images/shell.png",20,10,1);
		shellHigh->velocity.x = 30;
		shellHigh->velocity.y = 1;
		if(player->facingLeft == 1)
		{
			shellHigh->velocity.x =-30;
		}

		shellLow->position.x = player->position.x + 45;
		shellLow->position.y = player->position.y + 42;
		shellLow->sprite = loadSprite("images/shell.png",20,10,1);
		shellLow->velocity.x = 30;
		shellLow->velocity.y = -1;
		if(player->facingLeft == 1)
		{
			shellLow->velocity.x =-30;
		}
	}
}
Esempio n. 25
0
BaseSprite *AdTalkNode::getSprite(TDirection dir) {
	loadSprite();
	if (_sprite) {
		return _sprite;
	} else if (_spriteSet) {
		return _spriteSet->getSprite(dir);
	} else {
		return nullptr;
	}
}
Esempio n. 26
0
SsScene2901BigButton::SsScene2901BigButton(NeverhoodEngine *vm, Scene *parentScene, int which)
	: StaticSprite(vm, 900), _parentScene(parentScene), _which(which), _countdown1(0) {

	loadSprite(kSsScene2901BigButtonFileHashes[which], kSLFDefDrawOffset | kSLFDefPosition, 400);
	_collisionBounds.set(62, 94, 322, 350);
	setVisible(false);
	loadSound(0, 0xF3D420C8);
	SetUpdateHandler(&SsScene2901BigButton::update);
	SetMessageHandler(&SsScene2901BigButton::handleMessage);
}
Esempio n. 27
0
SsScene3009SymbolEdges::SsScene3009SymbolEdges(NeverhoodEngine *vm, int index)
	: StaticSprite(vm, 1400), _blinkCountdown(0) {

	loadSprite(kSsScene3009SymbolEdgesFileHashes[index], kSLFDefDrawOffset | kSLFDefPosition, 600);
	if (getGlobalVar(V_ROBOT_HIT))
		hide();
	else
		startBlinking();
	SetUpdateHandler(&SsScene3009SymbolEdges::update);
}
Esempio n. 28
0
void LoadAppGFX(void)
{
    IMAGE imgTmp;
    
    loadImage(&imgTmp, ".\\Gfx\\skidsmoke.hwg");
    loadSprite(&sprSkidSmoke, &imgTmp, 0, 0, 16, 16);
    killImage(&imgTmp);
    
    loadImage(&imgTmp, ".\\Gfx\\charsel.hwg");
    loadSprite(&sprCharsel, &imgTmp, 0, 0, 640, 480);
    killImage(&imgTmp);
    
    loadImage(&imgTmp, ".\\Gfx\\charselhaji.hwg");
    loadSprite(&sprCharselHaji, &imgTmp, 0, 0, 185, 259);
    killImage(&imgTmp);
    
    loadImage(&imgTmp, ".\\Gfx\\charselsumi.hwg");
    loadSprite(&sprCharselSumi, &imgTmp, 0, 0, 198, 266);
    killImage(&imgTmp);
}
Esempio n. 29
0
void SimonEngine::printInteractText(uint16 num, const char *string) {
	char convertedString[320];
	char *convertedString2 = convertedString;
	const char *string2 = string;
	uint16 height = 15;
	uint16 w = 0xFFFF;
	uint16 b, pixels, x;

	// It doesn't really matter what 'w' is to begin with, as long as it's
	// something that cannot be generated by getPixelLength(). The original
	// used 620, which was a potential problem.

	while (1) {
		string2 = getPixelLength(string, 620, pixels);
		if (*string2 == 0x00) {
			if (w == 0xFFFF)
				w = pixels;
			strcpy(convertedString2, string);
			break;
		}
		while (*string2 != ' ') {
			byte chr = *string2;
			pixels -= charWidth[chr];
			string2--;
		}
		if (w == 0xFFFF)
			w = pixels;
		b = string2 - string;
		strncpy(convertedString2, string, b);
		convertedString2 += b;
		*convertedString2++ = '\n';
		height += 15;
		string = string2;
	}

	// ScrollX
	x = _variableArray[251];		
	x += 20;

	if (num == 1)
		_interactY = 385;

	// Returned values for box definition
	_variableArray[51] = x;			
	_variableArray[52] = _interactY;
	_variableArray[53] = w;
	_variableArray[54] = height;

	stopAnimateSimon2(2, num + 6);
	renderString(num, 0, w, height, convertedString);
	loadSprite(4, 2, num + 6, x, _interactY, 12);

	_interactY += height;
}
Esempio n. 30
0
SsScene2901LocationButton::SsScene2901LocationButton(NeverhoodEngine *vm, Scene *parentScene, int which, uint index)
	: StaticSprite(vm, 900), _parentScene(parentScene), _index(index), _countdown1(0) {

	const NPoint &pt = kSsScene2901LocationButtonPoints[_index];

	loadSprite(kSsScene2901LocationButtonFileHashes[which * 6 + index], kSLFDefDrawOffset | kSLFDefPosition, 800);
	_collisionBounds.set(pt.x - 25, pt.y - 25, pt.x + 25, pt.y + 25);
	setVisible(false);
	loadSound(0, 0x440430C0);
	SetUpdateHandler(&SsScene2901LocationButton::update);
	SetMessageHandler(&SsScene2901LocationButton::handleMessage);
}