Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Relic

Pages: [1]
1
SFML projects / Pentads, yet another Tetris clone
« on: August 14, 2011, 08:27:14 am »
"Pentads" is yet another tetris clone. Nothing special, maybe a bit more difficult to play. Blocks are harder to fit. Meteorites do not let you relax.

http://img26.imageshack.us/img26/9214/pentadsle.jpg
http://img42.imageshack.us/img42/7866/pentadsplay.jpg

The game binary pack (for Windows) is here: http://www.mediafire.com/?d29pfm9jff9zn8m

License is simple. The game is free of charge. Do what you want with it except selling and removing copyright note.

Free music and sounds were borrowed from pacdv.com (see the following terms of use).  

TERMS OF USE: You may use the sound effects on this web site free of charge in your video, film, audio and multimedia productions but DO NOT e-sell them, post on a web site for download, or link directly to individual sound files. If you use these sound effects, please consider linking back to this site but you don't have to. http://www.pacdv.com/sounds

This game was mainly used as a test application for my game framework. Though it lacks important parts of user interface, namely settings dialog, save result dialog, message windows, etc., it is quite playable. It already has music and sound effects. I intend to finish this game as soon as possible (maybe ;-)).
In spite of lack of settings dialog, one can change a few options by editing the configuration file manually. In the bottom part of this file relevant tags of the configuration are described.
The game framework used for developing "Pentads" is not finished yet as well. For now GUI has only a few widgets: button, panel, picture and label. The GUI supports widget focus tab-order. A user can press Tab key to move focus forward and Shift-Tab to move focus backward. Pressing Enter against focused widget is equivalent to its left-mouse-clicking. For now only two buttons in the main menu have click event handlers: Game and Quit. Besides, the game can not be paused.

How to change options in the file config.xml.

Audio subsystem. One can switch on/off music and sounds and set volumes.

Code: [Select]
<subsystem name="audio">
  <item key="useMusic" value="true" />
  <item key="useSounds" value="true" />
  <item key="volumeMusic" value="50" />
  <item key="volumeSounds" value="50" />
</subsystem>

 
Game look. Default skin is "Haze". Who finds it too dull can choose a skin from the list: "Ocean", "Grass", "Lilac", "Honey", "Haze", "Pink", "Navy".
 
Code: [Select]
<subsystem name="game">
  <item key="look" value="Haze" />
</subsystem>
   
 
Key map. Sorry, so far it's somewhat inconvenient to change default keys. A user has to look at SFML source to be able to manually change constants for keys. Key assignments can be seen in the main game window (label "Keys").

The following aliases for game control keys are used:

"left2" is assigned to "LEFT"
"right2" .. to "RIGHT"
"up2" .. to "ROTATE"
"down2" .. to "DOWN"
"jump2" .. to "DROP"

Code: [Select]
<subsystem name="keymap">
  <item key="left2" value="291" />
  <item key="right2" value="292" />
  <item key="up2" value="293" />
  <item key="down2" value="294" />
  <item key="jump2" value="277" />
  <item key="menu" value="256" />
  <item key="pause" value="320" />
</subsystem>

2
Window / [SOLVED] Toggling input language...
« on: February 10, 2011, 08:57:10 am »
I've got a problem while toggling input language (Native/English) on the keyboard in my SFML application. In my OS Windows XP SP3 I set up the shortcut Shift+Ctrl for this option. But the language does not toggle. Other apps work fine. To do the trick I'm using the following key sequence: press Shift, press Ctrl, release Ctrl, press Alt, release Alt, release Shift.

Here is the test code:
Code: [Select]
#include "stdafx.h"
#include "SFML/Graphics.hpp"


int _tmain(int argc, _TCHAR* argv[])
{
  sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

sf::String str;
sf::Text text;

  while (window.IsOpened())
  {
    sf::Event evnt;
    while (window.GetEvent(evnt))
    {
      if (evnt.Type == sf::Event::Closed)
        window.Close();

      if (evnt.Type == sf::Event::TextEntered)
      {
str += evnt.Text.Unicode;
text.SetString(str);
      }
    }
 
    window.Clear();
    window.Draw(text);
    window.Display();
  }


return 0;
}

I guess there's something wrong with keyboard events handling. Is there any workaround for this behaviour? :?

3
General discussions / Using named colors
« on: October 13, 2010, 05:37:39 am »
Hi guys! This is my 1st post here. I'm working on my game engine that uses sfml. And I want to share portion of my (and betajaen's) code. If it is helpfull may be it is worth to be wikied.:)  
I think that pre-defined named colors are much more convenient than their digital equivalents. In my engine's graphics utility class I'm using the following enum that was borrowed from OGRE's addon Gorilla created by betajaen (license included). Unlike sfml's approach where pre-defined basic colors (Red, Blue etc.) are static objects, I use a convertion function that returns sf::Color. May be this code will be useful for somebody.

 
Code: [Select]
/*
    Gorilla
    -------
   
    Copyright (c) 2010 Robin Southern
                                                                                 
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
                                                                                 
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
                                                                                 
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
   
*/
namespace NamedColor
{
enum NamedColor
{
  None = 0, // No Color.                                                        
  AliceBlue=0xf0f8ff,      Gainsboro=0xdcdcdc,            MistyRose=0xffe4e1,    
  AntiqueWhite=0xfaebd7,   GhostWhite=0xf8f8ff,           Moccasin=0xffe4b5,      
  Aqua=0x00ffff,           Gold=0xffd700,                 NavajoWhite=0xffdead,  
  Aquamarine=0x7fffd4,     Goldenrod=0xdaa520,            Navy=0x000080,          
  Azure=0xf0ffff,          Gray=0x808080,                 OldLace=0xfdf5e6,      
  Beige=0xf5f5dc,          Green=0x008000,                Olive=0x808000,        
  Bisque=0xffe4c4,         GreenYellow=0xadff2f,          OliveDrab=0x6b8e23,    
  Black=0x000000,          Grey=0x808080,                 Orange=0xffa500,        
  BlanchedAlmond=0xffebcd, Honeydew=0xf0fff0,             OrangeRed=0xff4500,    
  Blue=0x0000ff,           HotPink=0xff69b4,              Orchid=0xda70d6,        
  BlueViolet=0x8a2be2,     IndianRed=0xcd5c5c,            PaleGoldenrod=0xeee8aa,
  Brown=0xa52a2a,          Indigo=0x4b0082,               PaleGreen=0x98fb98,    
  Burlywood=0xdeb887,      Ivory=0xfffff0,                PaleTurquoise=0xafeeee,
  CadetBlue=0x5f9ea0,      Khaki=0xf0e68c,                PaleVioletRed=0xdb7093,
  Chartreuse=0x7fff00,     Lavender=0xe6e6fa,             PapayaWhip=0xffefd5,    
  Chocolate=0xd2691e,      LavenderBlush=0xfff0f5,        PeachPuff=0xffdab9,    
  Coral=0xff7f50,          LawnGreen=0x7cfc00,            Peru=0xcd853f,          
  CornflowerBlue=0x6495ed, LemonChiffon=0xfffacd,         Pink=0xffc0cb,          
  Cornsilk=0xfff8dc,       LightBlue=0xadd8e6,            Plum=0xdda0dd,          
  Crimson=0xdc143c,        LightCoral=0xf08080,           PowderBlue=0xb0e0e6,    
  Cyan=0x00ffff,           LightCyan=0xe0ffff,            Purple=0x800080,        
  DarkBlue=0x00008b,       LightGoldenrodyellow=0xfafad2, Red=0xff0000,          
  DarkCyan=0x008b8b,       LightGray=0xd3d3d3,            RosyBrown=0xbc8f8f,    
  DarkGoldenrod=0xb8860b,  LightGreen=0x90ee90,           RoyalBlue=0x4169e1,    
  DarkGray=0xa9a9a9,       LightGrey=0xd3d3d3,            SaddleBrown=0x8b4513,  
  DarkGreen=0x006400,      LightPink=0xffb6c1,            Salmon=0xfa8072,        
  DarkGrey=0xa9a9a9,       LightSalmon=0xffa07a,          SandyBrown=0xf4a460,    
  DarkKhaki=0xbdb76b,      LightSeagreen=0x20b2aa,        SeaGreen=0x2e8b57,      
  DarkMagenta=0x8b008b,    LightSkyblue=0x87cefa,         SeaShell=0xfff5ee,      
  DarkOlivegreen=0x556b2f, LightSlategray=0x778899,       Sienna=0xa0522d,        
  DarkOrange=0xff8c00,     LightSlategrey=0x778899,       Silver=0xc0c0c0,        
  DarkOrchid=0x9932cc,     LightSteelblue=0xb0c4de,       SkyBlue=0x87ceeb,      
  DarkRed=0x8b0000,        LightYellow=0xffffe0,          SlateBlue=0x6a5acd,    
  DarkSalmon=0xe9967a,     Lime=0x00ff00,                 SlateGray=0x708090,    
  DarkSeagreen=0x8fbc8f,   LimeGreen=0x32cd32,            SlateGrey=0x708090,    
  DarkSlateblue=0x483d8b,  Linen=0xfaf0e6,                Snow=0xfffafa,          
  DarkSlategray=0x2f4f4f,  Magenta=0xff00ff,              SpringGreen=0x00ff7f,  
  DarkSlategrey=0x2f4f4f,  Maroon=0x800000,               SteelBlue=0x4682b4,    
  DarkTurquoise=0x00ced1,  MediumAquamarine=0x66cdaa,     Tan=0xd2b48c,          
  DarkViolet=0x9400d3,     MediumBlue=0x0000cd,           Teal=0x008080,          
  DeepPink=0xff1493,       MediumOrchid=0xba55d3,         Thistle=0xd8bfd8,      
  DeepSkyblue=0x00bfff,    MediumPurple=0x9370db,         Tomato=0xff6347,        
  DimGray=0x696969,        MediumSeaGreen=0x3cb371,       Turquoise=0x40e0d0,    
  DimGrey=0x696969,        MediumSlateBlue=0x7b68ee,      Violet=0xee82ee,        
  DodgerBlue=0x1e90ff,     MediumSpringGreen=0x00fa9a,    Wheat=0xf5deb3,        
  FireBrick=0xb22222,      MediumTurquoise=0x48d1cc,      White=0xffffff,        
  FloralWhite=0xfffaf0,    MediumBioletRed=0xc71585,      WhiteSmoke=0xf5f5f5,    
  ForestGreen=0x228b22,    MidnightBlue=0x191970,         Yellow=0xffff00,        
  Fuchsia=0xff00ff,        MintCream=0xf5fffa,            YellowGreen=0x9acd32    
};
} // namespace

//-----------------------------------------------------------------------------
class GraphUtils
{

public:

  static sf::Color ToSfColor(unsigned int namedColor, unsigned char alpha = 255);
};

Code: [Select]
//-----------------------------------------------------------------------------
sf::Color GraphUtils::ToSfColor(unsigned int namedColor, unsigned char alpha)
{
  union
  {
    unsigned int whole;
    unsigned char byte[4];
  };
 
  whole = namedColor;
 
  return sf::Color(byte[2], byte[1], byte[0], alpha);
};


Using named colors...
Code: [Select]

...
label.SetFrameColor(GraphUtils::ToSfColor(NamedColor::BlueViolet));
...

Pages: [1]