   DEXSOFT-Games: Robot Warrior 2.
  Dear Friends,we published new pack: Robot Warrior 2. Model packAnimated model  with 14 animations (!), 7754 triangles, 1 LOD stage (1174 triangles), textures in tga, and png format.First week rebate offer only 19.99€ instead of 29.99€33% rebateMore details on: www.dexsoft-games.com
from System import *from System.Drawing import Sizefrom System.Windows.Forms import Form, Application, MessageBox, FormBorderStylefrom SlimDX import *from SlimDX.Direct3D11 import *from SlimDX.DXGI import SwapChainDescription, SwapChainFlags, ModeDescription, SampleDescription, Usage, SwapEffect, Format, PresentFlags, Factory, WindowAssociationFlagsfrom SlimDX.D3DCompiler import *from SlimDX.Windows import MessagePumpclass GameObject:    def Render(self):   pass    def Tick(self):   pass class GraphicsDevice(IDisposable):    Context = property(lambda self: self.context)    Device = property(lambda self: self.device)    SwapChain = property(lambda self: self.swapChain)def __init__(self, control, fullscreen):   self.fullscreen = fullscreen   self.control = control    control.Resize += lambda sender, args: self.Resize()    swapChainDesc = self.CreateSwapChainDescription();   success,self.device,self.swapChain = Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, Array[FeatureLevel]([FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0]), swapChainDesc)   self.context = self.Device.ImmediateContext    with self.swapChain.GetParent[Factory]() as factory:  factory.SetWindowAssociation(self.control.Handle, WindowAssociationFlags.IgnoreAll)    with Resource.FromSwapChain[Texture2D](self.swapChain, 0) as backBuffer:  self.backBufferRTV = RenderTargetView(self.Device, backBuffer)   self.Resize()   def CreateSwapChainDescription(self):   swapChainDesc = SwapChainDescription()   swapChainDesc.IsWindowed = not self.fullscreen   swapChainDesc.BufferCount = 1   swapChainDesc.ModeDescription = ModeDescription(self.control.ClientSize.Width, self.control.ClientSize.Height, Rational(60, 1), Format.R8G8B8A8_UNorm)   swapChainDesc.Flags = SwapChainFlags.None   swapChainDesc.SwapEffect = SwapEffect.Discard   swapChainDesc.Usage = Usage.RenderTargetOutput   swapChainDesc.SampleDescription = SampleDescription(1, 0)   swapChainDesc.OutputHandle = self.control.Handle   return swapChainDesc    def Resize(self):   self.Context.ClearState()   self.backBufferRTV.Dispose()   self.swapChain.ResizeBuffers(1, self.control.ClientSize.Width, self.control.ClientSize.Height, Format.R8G8B8A8_UNorm, SwapChainFlags.None)   with Resource.FromSwapChain[Texture2D](self.swapChain, 0) as backBuffer:  self.backBufferRTV = RenderTargetView(self.Device, backBuffer)   self.Context.Rasterizer.SetViewports(Viewport(0, 0, self.control.ClientSize.Width, self.control.ClientSize.Height, 0.0, 1.0))    def BeginRender(self):   self.Context.ClearRenderTargetView(self.backBufferRTV, Color4(0, 0, 0, 0))   self.Context.OutputMerger.SetTargets(self.backBufferRTV) def EndRender(self):   self.swapChain.Present(0, PresentFlags.None)    def Dispose(self):   self.backBufferRTV.Dispose()   self.swapChain.Dispose()   self.device.Dispose()class TriangleObject(GameObject):    def __init__(self, game):   self.game = game   device = game.GraphicsDevice.Device   context = game.GraphicsDevice.Context    err = clr.Reference[str]()   with ShaderBytecode.CompileFromFile(&quot;SimpleTriangle10.fx&quot;, &quot;fx_5_0&quot;, ShaderFlags.None, EffectFlags.None, None, None, err) as shaderByteCode:  self.effect = Effect(device, shaderByteCode)   shaderTechnique = self.effect.GetTechniqueByIndex(0)   self.shaderPass = shaderTechnique.GetPassByIndex(0)   sig = self.shaderPass.Description.Signature   self.inputLayout = InputLayout(device, sig, Array[InputElement]([InputElement(&quot;POSITION&quot;, 0, Format.R32G32B32A32_Float, 0, 0), InputElement(&quot;COLOR&quot;, 0, Format.R32G32B32A32_Float, 16, 0)]))    bufferDesc = BufferDescription(3 * 32, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)   self.vertexBuffer = Buffer(device, bufferDesc)    stream = context.MapSubresource(self.vertexBuffer, 0, 3 * 32, MapMode.WriteDiscard, MapFlags.None).Data   data = Array[Vector4]([  Vector4(0.0, 0.5, 0.5, 1.0), Vector4(1.0, 0.0, 0.0, 1.0),  Vector4(0.5, -0.5, 0.5, 1.0), Vector4(0.0, 1.0, 0.0, 1.0),  Vector4(-0.5, -0.5, 0.5, 1.0), Vector4(0.0, 0.0, 1.0, 1.0)   ])   stream.WriteRange(data)   context.UnmapSubresource(self.vertexBuffer, 0)    def Render(self):   context = self.game.GraphicsDevice.Context   context.InputAssembler.InputLayout = self.inputLayout   context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList   context.InputAssembler.SetVertexBuffers(0, VertexBufferBinding(self.vertexBuffer, 32, 0))   self.shaderPass.Apply(context)   context.Draw(3, 0)def Dispose(self):   self.effect.Dispose()   self.inputLayout.Dispose()   self.vertexBuffer.Dispose() class Game(IDisposable):    GraphicsDevice = property(lambda self: self.graphicsDevice)def __init__(self, width, height, fullscreen = False):   self.fullscreen = fullscreen   self.form = GameForm(width, height, fullscreen)   self.form.Visible = True   self.graphicsDevice = GraphicsDevice(self.form, self.fullscreen)   self.gameObjects = [TriangleObject(self)]def Run(self):   Application.Idle += self.OnIdle   Application.Run(self.form)    def OnIdle(self, ea, sender):   while MessagePump.IsApplicationIdle:  self.Update()  self.Render()def Update(self):   for i in self.gameObjects:  i.Tick()def Render(self):   self.GraphicsDevice.BeginRender()   for i in self.gameObjects:  i.Render()   self.GraphicsDevice.EndRender()def Dispose(self):   self.GraphicsDevice.Dispose()   for i in self.gameObjects:  if 'Dispose' in dir(i): i.Dispose()   self.form.Dispose(True)class GameForm(Form):    def __init__(self, width, height, fullscreen):   self.ClientSize = Size(width, height)   if fullscreen:  self.FormBorderStyle = FormBorderStyle.Noneif __name__ == &quot;__main__&quot;:    try:   with Game(640, 480) as game:  game.Run()    except Exception as e:   MessageBox.Show(e.ToString())#include <iostream>#include <string>class Game;class Intro;class GameState {public:virtual void Update(Game* game) = 0;virtual ~GameState() {}}; class Intro : public GameState {public:virtual void Update(Game* game);virtual ~Intro() {}};class MainMenu : public GameState {public:virtual void Update(Game* game);virtual ~MainMenu() {}};class MainGame : public GameState {public:virtual void Update(Game* game);virtual ~MainGame() {}};class Game {public:Game() : currentState(new Intro), oldState(nullptr) {}void DoMainLoop() {while(HandleMessages()) {if(currentState)currentState->Update(this);elsebreak;if(oldState) {delete oldState;oldState = nullptr;}}}void SetState(GameState* newState) {oldState = currentState;currentState = newState;}~Game() {delete currentState;}private:bool HandleMessages() {return true;}GameState* oldState;GameState* currentState;};void Intro::Update(Game* game) {std::cout<<"Intro!"<<std::endl;game->SetState(new MainMenu());}void MainMenu::Update(Game* game) {std::cout<<"Main Menu!"<<std::endl;std::cout<<"Please choose an option:"<<std::endl;std::cout<<"    1. Play the game!"<<std::endl<<"    2. Exit!"<<std::endl;int choice;std::cin>>choice;switch(choice) {case 1:game->SetState(new MainGame());break;case 2:game->SetState(nullptr);break;default:std::cout<<"Invalid choice!"<<std::endl;}}void MainGame::Update(Game* game) {std::cout<<"Main game!"<<std::endl;std::string name;std::cout<<"Enter your name: ";std::cin.ignore(10, '\n');std::getline(std::cin, name);std::cout<<"Hello, "<<name<<"."<<std::endl;char c;std::cout<<"Would you like to exit to the main menu? ";std::cin>>c;if(c == 'y' || c == 'Y')game->SetState(new MainMenu());}int main() {Game game;game.DoMainLoop();};from System import *from System.Drawing import Sizefrom System.Windows.Forms import Form, Application, MessageBox, FormBorderStylefrom SlimDX import *from SlimDX.Direct3D11 import *from SlimDX.DXGI import SwapChainDescription, SwapChainFlags, ModeDescription, SampleDescription, Usage, SwapEffect, Format, PresentFlags, Factory, WindowAssociationFlagsfrom SlimDX.D3DCompiler import *from SlimDX.Windows import MessagePumpclass GameObject:    def Render(self):   pass    def Tick(self):   pass class GraphicsDevice(IDisposable):    Context = property(lambda self: self.context)    Device = property(lambda self: self.device)    SwapChain = property(lambda self: self.swapChain)def __init__(self, control, fullscreen):   self.fullscreen = fullscreen   self.control = control    control.Resize += lambda sender, args: self.Resize()    swapChainDesc = self.CreateSwapChainDescription();   success,self.device,self.swapChain = Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, Array[FeatureLevel]([FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0]), swapChainDesc)   self.context = self.Device.ImmediateContext    with self.swapChain.GetParent[Factory]() as factory:  factory.SetWindowAssociation(self.control.Handle, WindowAssociationFlags.IgnoreAll)    with Resource.FromSwapChain[Texture2D](self.swapChain, 0) as backBuffer:  self.backBufferRTV = RenderTargetView(self.Device, backBuffer)   self.Resize()   def CreateSwapChainDescription(self):   swapChainDesc = SwapChainDescription()   swapChainDesc.IsWindowed = not self.fullscreen   swapChainDesc.BufferCount = 1   swapChainDesc.ModeDescription = ModeDescription(self.control.ClientSize.Width, self.control.ClientSize.Height, Rational(60, 1), Format.R8G8B8A8_UNorm)   swapChainDesc.Flags = SwapChainFlags.None   swapChainDesc.SwapEffect = SwapEffect.Discard   swapChainDesc.Usage = Usage.RenderTargetOutput   swapChainDesc.SampleDescription = SampleDescription(1, 0)   swapChainDesc.OutputHandle = self.control.Handle   return swapChainDesc    def Resize(self):   self.Context.ClearState()   self.backBufferRTV.Dispose()   self.swapChain.ResizeBuffers(1, self.control.ClientSize.Width, self.control.ClientSize.Height, Format.R8G8B8A8_UNorm, SwapChainFlags.None)   with Resource.FromSwapChain[Texture2D](self.swapChain, 0) as backBuffer:  self.backBufferRTV = RenderTargetView(self.Device, backBuffer)   self.Context.Rasterizer.SetViewports(Viewport(0, 0, self.control.ClientSize.Width, self.control.ClientSize.Height, 0.0, 1.0))    def BeginRender(self):   self.Context.ClearRenderTargetView(self.backBufferRTV, Color4(0, 0, 0, 0))   self.Context.OutputMerger.SetTargets(self.backBufferRTV) def EndRender(self):   self.swapChain.Present(0, PresentFlags.None)    def Dispose(self):   self.backBufferRTV.Dispose()   self.swapChain.Dispose()   self.device.Dispose()class TriangleObject(GameObject):    def __init__(self, game):   self.game = game   device = game.GraphicsDevice.Device   context = game.GraphicsDevice.Context    err = clr.Reference[str]()   with ShaderBytecode.CompileFromFile(&quot;SimpleTriangle10.fx&quot;, &quot;fx_5_0&quot;, ShaderFlags.None, EffectFlags.None, None, None, err) as shaderByteCode:  self.effect = Effect(device, shaderByteCode)   shaderTechnique = self.effect.GetTechniqueByIndex(0)   self.shaderPass = shaderTechnique.GetPassByIndex(0)   sig = self.shaderPass.Description.Signature   self.inputLayout = InputLayout(device, sig, Array[InputElement]([InputElement(&quot;POSITION&quot;, 0, Format.R32G32B32A32_Float, 0, 0), InputElement(&quot;COLOR&quot;, 0, Format.R32G32B32A32_Float, 16, 0)]))    bufferDesc = BufferDescription(3 * 32, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)   self.vertexBuffer = Buffer(device, bufferDesc)    stream = context.MapSubresource(self.vertexBuffer, 0, 3 * 32, MapMode.WriteDiscard, MapFlags.None).Data   data = Array[Vector4]([  Vector4(0.0, 0.5, 0.5, 1.0), Vector4(1.0, 0.0, 0.0, 1.0),  Vector4(0.5, -0.5, 0.5, 1.0), Vector4(0.0, 1.0, 0.0, 1.0),  Vector4(-0.5, -0.5, 0.5, 1.0), Vector4(0.0, 0.0, 1.0, 1.0)   ])   stream.WriteRange(data)   context.UnmapSubresource(self.vertexBuffer, 0)    def Render(self):   context = self.game.GraphicsDevice.Context   context.InputAssembler.InputLayout = self.inputLayout   context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList   context.InputAssembler.SetVertexBuffers(0, VertexBufferBinding(self.vertexBuffer, 32, 0))   self.shaderPass.Apply(context)   context.Draw(3, 0)def Dispose(self):   self.effect.Dispose()   self.inputLayout.Dispose()   self.vertexBuffer.Dispose() class Game(IDisposable):    GraphicsDevice = property(lambda self: self.graphicsDevice)def __init__(self, width, height, fullscreen = False):   self.fullscreen = fullscreen   self.form = GameForm(width, height, fullscreen)   self.form.Visible = True   self.graphicsDevice = GraphicsDevice(self.form, self.fullscreen)   self.gameObjects = [TriangleObject(self)]def Run(self):   Application.Idle += self.OnIdle   Application.Run(self.form)    def OnIdle(self, ea, sender):   while MessagePump.IsApplicationIdle:  self.Update()  self.Render()def Update(self):   for i in self.gameObjects:  i.Tick()def Render(self):   self.GraphicsDevice.BeginRender()   for i in self.gameObjects:  i.Render()   self.GraphicsDevice.EndRender()def Dispose(self):   self.GraphicsDevice.Dispose()   for i in self.gameObjects:  if 'Dispose' in dir(i): i.Dispose()   self.form.Dispose(True)class GameForm(Form):    def __init__(self, width, height, fullscreen):   self.ClientSize = Size(width, height)   if fullscreen:  self.FormBorderStyle = FormBorderStyle.Noneif __name__ == &quot;__main__&quot;:    try:   with Game(640, 480) as game:  game.Run()    except Exception as e:   MessageBox.Show(e.ToString());from System import *from System.Drawing import Sizefrom System.Windows.Forms import Form, Application, MessageBox, FormBorderStylefrom SlimDX import *from SlimDX.Direct3D11 import *from SlimDX.DXGI import SwapChainDescription, SwapChainFlags, ModeDescription, SampleDescription, Usage, SwapEffect, Format, PresentFlags, Factory, WindowAssociationFlagsfrom SlimDX.D3DCompiler import *from SlimDX.Windows import MessagePumpclass GameObject:    def Render(self):   pass    def Tick(self):   pass class GraphicsDevice(IDisposable):    Context = property(lambda self: self.context)    Device = property(lambda self: self.device)    SwapChain = property(lambda self: self.swapChain)def __init__(self, control, fullscreen):   self.fullscreen = fullscreen   self.control = control    control.Resize += lambda sender, args: self.Resize()    swapChainDesc = self.CreateSwapChainDescription();   success,self.device,self.swapChain = Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, Array[FeatureLevel]([FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0]), swapChainDesc)   self.context = self.Device.ImmediateContext    with self.swapChain.GetParent[Factory]() as factory:  factory.SetWindowAssociation(self.control.Handle, WindowAssociationFlags.IgnoreAll)    with Resource.FromSwapChain[Texture2D](self.swapChain, 0) as backBuffer:  self.backBufferRTV = RenderTargetView(self.Device, backBuffer)   self.Resize()   def CreateSwapChainDescription(self):   swapChainDesc = SwapChainDescription()   swapChainDesc.IsWindowed = not self.fullscreen   swapChainDesc.BufferCount = 1   swapChainDesc.ModeDescription = ModeDescription(self.control.ClientSize.Width, self.control.ClientSize.Height, Rational(60, 1), Format.R8G8B8A8_UNorm)   swapChainDesc.Flags = SwapChainFlags.None   swapChainDesc.SwapEffect = SwapEffect.Discard   swapChainDesc.Usage = Usage.RenderTargetOutput   swapChainDesc.SampleDescription = SampleDescription(1, 0)   swapChainDesc.OutputHandle = self.control.Handle   return swapChainDesc    def Resize(self):   self.Context.ClearState()   self.backBufferRTV.Dispose()   self.swapChain.ResizeBuffers(1, self.control.ClientSize.Width, self.control.ClientSize.Height, Format.R8G8B8A8_UNorm, SwapChainFlags.None)   with Resource.FromSwapChain[Texture2D](self.swapChain, 0) as backBuffer:  self.backBufferRTV = RenderTargetView(self.Device, backBuffer)   self.Context.Rasterizer.SetViewports(Viewport(0, 0, self.control.ClientSize.Width, self.control.ClientSize.Height, 0.0, 1.0))    def BeginRender(self):   self.Context.ClearRenderTargetView(self.backBufferRTV, Color4(0, 0, 0, 0))   self.Context.OutputMerger.SetTargets(self.backBufferRTV) def EndRender(self):   self.swapChain.Present(0, PresentFlags.None)    def Dispose(self):   self.backBufferRTV.Dispose()   self.swapChain.Dispose()   self.device.Dispose()class TriangleObject(GameObject):    def __init__(self, game):   self.game = game   device = game.GraphicsDevice.Device   context = game.GraphicsDevice.Context    err = clr.Reference[str]()   with ShaderBytecode.CompileFromFile(&quot;SimpleTriangle10.fx&quot;, &quot;fx_5_0&quot;, ShaderFlags.None, EffectFlags.None, None, None, err) as shaderByteCode:  self.effect = Effect(device, shaderByteCode)   shaderTechnique = self.effect.GetTechniqueByIndex(0)   self.shaderPass = shaderTechnique.GetPassByIndex(0)   sig = self.shaderPass.Description.Signature   self.inputLayout = InputLayout(device, sig, Array[InputElement]([InputElement(&quot;POSITION&quot;, 0, Format.R32G32B32A32_Float, 0, 0), InputElement(&quot;COLOR&quot;, 0, Format.R32G32B32A32_Float, 16, 0)]))    bufferDesc = BufferDescription(3 * 32, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0)   self.vertexBuffer = Buffer(device, bufferDesc)    stream = context.MapSubresource(self.vertexBuffer, 0, 3 * 32, MapMode.WriteDiscard, MapFlags.None).Data   data = Array[Vector4]([  Vector4(0.0, 0.5, 0.5, 1.0), Vector4(1.0, 0.0, 0.0, 1.0),  Vector4(0.5, -0.5, 0.5, 1.0), Vector4(0.0, 1.0, 0.0, 1.0),  Vector4(-0.5, -0.5, 0.5, 1.0), Vector4(0.0, 0.0, 1.0, 1.0)   ])   stream.WriteRange(data)   context.UnmapSubresource(self.vertexBuffer, 0)    def Render(self):   context = self.game.GraphicsDevice.Context   context.InputAssembler.InputLayout = self.inputLayout   context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList   context.InputAssembler.SetVertexBuffers(0, VertexBufferBinding(self.vertexBuffer, 32, 0))   self.shaderPass.Apply(context)   context.Draw(3, 0)def Dispose(self):   self.effect.Dispose()   self.inputLayout.Dispose()   self.vertexBuffer.Dispose() class Game(IDisposable):    GraphicsDevice = property(lambda self: self.graphicsDevice)def __init__(self, width, height, fullscreen = False):   self.fullscreen = fullscreen   self.form = GameForm(width, height, fullscreen)   self.form.Visible = True   self.graphicsDevice = GraphicsDevice(self.form, self.fullscreen)   self.gameObjects = [TriangleObject(self)]def Run(self):   Application.Idle += self.OnIdle   Application.Run(self.form)    def OnIdle(self, ea, sender):   while MessagePump.IsApplicationIdle:  self.Update()  self.Render()def Update(self):   for i in self.gameObjects:  i.Tick()def Render(self):   self.GraphicsDevice.BeginRender()   for i in self.gameObjects:  i.Render()   self.GraphicsDevice.EndRender()def Dispose(self):   self.GraphicsDevice.Dispose()   for i in self.gameObjects:  if 'Dispose' in dir(i): i.Dispose()   self.form.Dispose(True)class GameForm(Form):    def __init__(self, width, height, fullscreen):   self.ClientSize = Size(width, height)   if fullscreen:  self.FormBorderStyle = FormBorderStyle.Noneif __name__ == &quot;__main__&quot;:    try:   with Game(640, 480) as game:  game.Run()    except Exception as e:   MessageBox.Show(e.ToString());