This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const double PI=3.14159265358979323846; | |
double r=100; | |
int sides=10; | |
glBegin(GL_LINE_STRIP); | |
for(int i=0;i<sides;i++){ | |
double angle=i*2*PI/sides; | |
glVertex2d(400+r*cos(angle),300+r*sin(angle)); | |
} | |
glEnd(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (App.isOpen()) | |
{ | |
// Process events | |
sf::Event Event; | |
while (App.pollEvent(Event)) | |
{ | |
// Close window : exit | |
if (Event.type == sf::Event::Closed) | |
App.close(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static void bounce(Shape shape1, Shape shape2) | |
{ | |
Vector2 displacement = shape1._position - shape2._position; | |
Vector2 closingspeed = shape1._velocity - shape2._velocity; | |
//check if they are already moving apart | |
if(Vector2.Dot(displacement,closingspeed)>=0){ | |
return;// if moving apart, do nothing | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Texture2D t; //base for the | |
protected override void LoadContent() | |
{ | |
// create 1x1 texture for line drawing | |
t = new Texture2D(GraphicsDevice, 1, 1); | |
t.SetData<Color>( | |
new Color[] { Color.White });// fill the texture with white | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glTranslated(550,250,0); | |
glRotated(angle,0,0,1); | |
glTranslated(-550,-250,0); | |
glBegin(GL_LINE_LOOP); | |
glVertex2d(500,200); | |
glVertex2d(600,200); | |
glVertex2d(600,300); | |
glVertex2d(500,300); | |
glEnd(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////// | |
// Headers | |
//////////////////////////////////////////////////////////// | |
#include "stdafx.h" | |
#ifdef _DEBUG | |
#pragma comment(lib,"sfml-graphics-d.lib") | |
#pragma comment(lib,"sfml-audio-d.lib") | |
#pragma comment(lib,"sfml-system-d.lib") | |
#pragma comment(lib,"sfml-window-d.lib") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*+++++++++++++++++++++++++++++++++++++++++ | |
Some sample code showing how to do basic vector operations with assimp | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ | |
// create a 3d Vector | |
aiVector3D a(1.0f,2.0f,3.0f); | |
aiVector3D b=a; //copy vector to another | |
b.x=0.f; //assign value to x component of b | |
//out put a vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int vpw = graphics.GraphicsDevice.Viewport.Width; | |
int vph = graphics.GraphicsDevice.Viewport.Height; | |
Rectangle rect = new Rectangle(0, 0, vpw, vph); | |
spriteBatch.Begin(); | |
//construct a rectangle to select an area of background to draw | |
//position(upper left of) rectangle is camera position minus halh size of viewport | |
Rectangle terrainRect=new Rectangle( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//drawing enemies with a moving camera | |
Vector3 cameraPos = new Vector3(-camera.Position.X, -camera.Position.Y, 0); | |
Matrix cameraTrans = Matrix.CreateTranslation(cameraPos); | |
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null,cameraTrans); | |
foreach(Sprite s in sprites) | |
s.Draw(gameTime,spriteBatch, true); | |
spriteBatch.End(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, null, null); | |
spriteBatch.Draw(clouds, | |
new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, | |
graphics.GraphicsDevice.Viewport.Height), | |
new Rectangle((int)cloudPos.X, (int)cloudPos.Y, 300,300), | |
Color.White); | |
spriteBatch.End(); |
OlderNewer