public override void render(Game game, World world, Camera camera, Vector3 position, int meta) { if(life > 2){ world.prepareModelMatrix(camera, position, camera.rotation.Y+angle); FrameManager.shot1.render(game); } }
public static void initFrames(Game game) { noTexture = new Frame(game, RenderGroup.makeTextureCoords(0, 0)); playerDefault = new Frame(game, RenderGroup.makeTextureCoords(3, 0)); tree = new Frame(game, RenderGroup.makeTextureCoords(5, 0)); shot1 = new Frame(game, RenderGroup.makeTextureCoords(6, 0)); swing1 = new Frame(game, RenderGroup.makeTextureCoords(7, 0)); }
public static void init(Game game) { for (int i = 0; i < walls.Length;i++ ) { if (walls[i] != null) { walls[i].initWall(game); } } }
public Gui(Game game, Gui holder, Rectangle bounds) { this.bounds = bounds; init(game); this.holder = holder; if(holder == null){ this.renderGroup = new RenderGroup(game); } dirty = true; }
public override void clientSimUpdate(Game game, World world) { life++; if (!remove) { if (move(world, moveTarget * moveSpeed)) { remove = true; if (!game.isMP) { world.removeEntity(entityId); } } } }
public void update(Game game) { keyboardState = Keyboard.GetState(); mouseState = Mouse.GetCursorState(); lastMousePosition = mousePosition; mousePosition = MathCustom.toVector2(game.PointToClient(new System.Drawing.Point(mouseState.X, mouseState.Y))); foreach(KeyBind keyBind in keyBindList){ keyBind.pressed = !keyBind.down && isKeyDown(keyBind, game); keyBind.released = keyBind.down && !isKeyDown(keyBind, game); keyBind.down = isKeyDown(keyBind, game); } }
public World(Game game, int width, int height, byte worldId) { this.game = game; wallGrid = new byte[width, height]; this.width = width; this.height = height; this.worldId = worldId; renderGroupXLow = new RenderGroup(game); renderGroupXHigh = new RenderGroup(game); renderGroupZLow = new RenderGroup(game); renderGroupZHigh = new RenderGroup(game); renderGroupTop = new RenderGroup(game); renderGroupFloor = new RenderGroup(game); }
public void update(Game game) { updateGui(game); if (holder == null) { if(game.inputControl.leftClick.pressed){ distributeEvent(new GuiEvent(GuiEventType.mousePressed, game.inputControl.mousePosition), game); } if (game.inputControl.leftClick.released) { distributeEvent(new GuiEvent(GuiEventType.mouseReleased, game.inputControl.mousePosition), game); } if (game.inputControl.mousePosition != game.inputControl.lastMousePosition) { distributeEvent(new GuiEvent(GuiEventType.mouseMoved, game.inputControl.mousePosition), game); } /*while(game.inputControl.hasKeyEvent()){ distributeEvent(new GuiKeyEvent(GuiEventType.keyTyped, game.inputControl.takeKeyEvent()), game); }*/ } foreach (Gui g in heldGuiList) { g.update(game); if(g.dirty){ dirty = true; g.dirty = false; } } if (dirty && holder == null) { dirty = false; renderGroup.begin(BeginMode.Quads); foreach (Gui g in heldGuiList) { g.updateRenderGroup(game, renderGroup); } updateRenderGroup(game, renderGroup); renderGroup.end(); Console.WriteLine("Render Group Updated"); } }
internal void update(Game game) { /*if(ks.IsKeyDown(Key.Space)){ position.Y -= moveSpeed; } if (ks.IsKeyDown(Key.LShift)) { position.Y += moveSpeed; }*/ if (game.inputControl.keyRotateLeft.down) { rotation.Y -= yRotSpeed; if (rotation.Y < 0) { rotation.Y += MathCustom.r360; } } if (game.inputControl.keyRotateRight.down) { rotation.Y += yRotSpeed; if (rotation.Y > MathCustom.r360) { rotation.Y -= MathCustom.r360; } } if (game.inputControl.keyRotateUp.down) { rotation.X += MathCustom.r1; if(rotation.X > MathCustom.r89){ rotation.X = MathCustom.r89; } } if (game.inputControl.keyRotateDown.down) { rotation.X -= MathCustom.r1; if (rotation.X < 0) { rotation.X = 0; } } //Console.WriteLine(position); //Console.WriteLine(rotation); }
public World(Game game) : this(game, 100, 100, 0) { }
internal void update(Game game) { if (markToResetRenderGroup) { resetRenderGroup(); markToResetRenderGroup = false; } foreach(Entity e in entityList.Values){ if(!game.isMP){ e.update(this); } else { e.clientSimUpdate(game, this); } e.clientUpdate(game, this); } while (entityAddList.Count > 0) { if (!entityList.ContainsKey(entityAddList[0].entityId)) { entityList.Add(entityAddList[0].entityId, entityAddList[0]); } else { Console.WriteLine("Can't add: " + entityAddList[0].entityId); } entityAddList.RemoveAt(0); } while (entityRemoveList.Count > 0) { entityList.Remove(entityRemoveList[0]); entityRemoveList.RemoveAt(0); } }
internal void render(Game game, Camera camera) { GL.UseProgram(game.glProgram); GL.UniformMatrix4(game.modelMatrixLocation, 1, false, game.Matrix4ToArray(camera.getModelMatrix())); GL.UniformMatrix4(game.perspectiveMatrixLocation, 1, false, game.Matrix4ToArray(game.perspectiveMatrix)); GL.BindTexture(TextureTarget.Texture2D, game.texturesId); if (camera.rotation.Y > MathCustom.r180 && camera.rotation.Y < MathCustom.r360) renderGroupXLow.render(game); if (camera.rotation.Y > 0 && camera.rotation.Y < MathCustom.r180) renderGroupXHigh.render(game); if (camera.rotation.Y > MathCustom.r90 && camera.rotation.Y < MathCustom.r270) renderGroupZLow.render(game); if ((camera.rotation.Y > MathCustom.r270 && camera.rotation.Y < MathCustom.r360) || (camera.rotation.Y > 0 && camera.rotation.Y < MathCustom.r90)) renderGroupZHigh.render(game); renderGroupTop.render(game); renderGroupFloor.render(game); Wall w; //Vector3 v; renderList.Clear(); foreach (Entity e in entityList.Values) { if ((e.position + camera.position).LengthSquared < entityRenderDistanceSquared) { e.addRenderable(ref renderList, camera); //e.render(game, this, camera); } } int xMin = Math.Max((int)((-camera.position.X) - blockRenderDistance), 0); int yMin = Math.Max((int)((-camera.position.Z) - blockRenderDistance), 0); int xMax = Math.Min((int)((-camera.position.X) + blockRenderDistance), width); int yMax = Math.Min((int)((-camera.position.Z) + blockRenderDistance), height); foreach (Point v in flatRenderList) { w = Wall.getWall(wallGrid[v.X, v.Y]); if (w.hasFlag(WallFlag.flat)) { renderList.Add(new Object3<Vector3, Renderable, int>(new Vector3(v.X, 0, v.Y), w, 0)); /*v = new Vector3(i, 0, j); GL.UniformMatrix4(mm, 1, false, game.Matrix4ToArray(camera.getFlatMatrix(v))); w.render(game, this, camera);*/ } } float l = camera.rotation.Y - MathCustom.r180; Vector3 c = -camera.position + new Vector3( (float)(-Math.Sin(l) * 100), MathCustom.sin45Times100, (float)(Math.Cos(l) * 100)); renderList.Sort( delegate( Object3<Vector3, Renderable, int> first, Object3<Vector3, Renderable, int> second) { return (first.x - c).LengthSquared.CompareTo( (second.x - c).LengthSquared); } ); //Console.WriteLine(); foreach (Object3<Vector3, Renderable, int> element in renderList) { //GL.UniformMatrix4(mm, 1, false, game.Matrix4ToArray(camera.getFlatMatrix(element.Key))); //Console.WriteLine((element.Key - c).LengthSquared+": "+element.Value.GetType().Name); element.y.render(game, this, camera, element.x, element.z); } }
public GuiButton(Game game, Gui holder, Rectangle rectangle, String text, Func<Gui, Game, bool> function) : base(game, holder, rectangle) { this.text = text; this.function = function; }
protected override void updateRenderGroup(Game game, RenderGroup renderGroup) { renderGroup.addGuiRectangle(buttonDown ? bounds : (bounds - buttonOffset), ColorMaker.gray(.3f)); renderGroup.addGuiRectangle(bounds + buttonOffset, ColorMaker.gray(.2f)); renderGroup.addGuiText((buttonDown ? bounds.position : (bounds.position - buttonOffset)) + bounds.halfSize + new Vector2(-(renderGroup.stringSize(text) / 2), -4), text, ColorMaker.white); }
public override void render(Game game, World world, Camera camera, Vector3 position, int meta) { world.prepareModelMatrix(camera, position); FrameManager.playerDefault.render(game); }
protected override void processEvent(GuiEvent guiEvent, Game game, bool inGui) { if (guiEvent.type == GuiEventType.mousePressed) { if (inGui) { this.holder.focus = this; } } else if (guiEvent.type == GuiEventType.keyTyped) { if(inGui){ if (this.holder.focus == this) { } } } }
protected override void updateGui(Game game) { }
protected override void init(Game game) { }
public GuiTextInput(Game game, Gui holder, Rectangle rectangle, String text) : base(game, holder, rectangle) { this.text = text; }
protected override void processEvent(GuiEvent guiEvent, Game game, bool inGui) { if(guiEvent.type == GuiEventType.mousePressed){ if(inGui){ function.Invoke(this, game); } } else if (guiEvent.type == GuiEventType.mouseMoved) { if (inGui && !buttonDown) { buttonDown = true; dirty = true; } else if (!inGui && buttonDown) { buttonDown = false; dirty = true; } } }
public Frame(Game game, Vector2[] textureCoords) { this.textureCoords = textureCoords; renderGroup = new RenderGroup(game); resetRenderGroup(); }
internal bool hasKeyEvent(Game game) { throw new NotImplementedException(); }
public void render(Game game) { renderGroup.render(game); }
protected abstract void updateRenderGroup(Game game, RenderGroup renderGroup);
public virtual void resize(Game game) { }
private GuiEvent distributeEvent(GuiEvent guiEvent, Game game) { foreach (Gui g in heldGuiList) { if(guiEvent.type == GuiEventType.cancel){ return guiEvent; } guiEvent = g.distributeEvent(guiEvent, game); } processEvent(guiEvent, game, bounds.contains(guiEvent.mousePosition)); return guiEvent; }
private bool isKeyDown(KeyBind keyBind, Game game) { return game.Focused ? (keyBind.isKey ? keyboardState.IsKeyDown(keyBind.kId) : mouseState.IsButtonDown(keyBind.mbId)) : false; }
protected abstract void updateGui(Game game);
public Game() : base(640, 480, GraphicsMode.Default, "Viking Game", GameWindowFlags.Default) { debugInstanceOnly = this; Run(60); }
public virtual void loadFromOtherGui(Game game, Gui other) { if (holder == null) { distributeEvent(new GuiEvent(GuiEventType.mouseMoved, game.inputControl.mousePosition), game); } }