Hello Guest

Author Topic: Problem On Pong Video  (Read 1667 times)

0 Members and 1 Guest are viewing this topic.

4test

  • Member
  • Posts: 2
    • View Profile
Problem On Pong Video
« on: April 15, 2015, 01:28:47 AM »
Global.PlayerOne.Controller.Up and Global.PlayerOne.Controller.Down isn't there now. How can i fix this?

BitteWenden

  • Member
  • Posts: 13
    • View Profile
Re: Problem On Pong Video
« Reply #1 on: April 15, 2015, 04:12:02 AM »
Can you share your code of the Global class with us?
« Last Edit: April 15, 2015, 09:01:36 AM by BitteWenden »

4test

  • Member
  • Posts: 2
    • View Profile
Re: Problem On Pong Video
« Reply #2 on: April 15, 2015, 04:23:36 AM »

BitteWenden

  • Member
  • Posts: 13
    • View Profile
Re: Problem On Pong Video
« Reply #3 on: April 15, 2015, 07:30:39 AM »
Thanks.
First of all the axis thing. You don't need to apply the keys manually, Otter has two cool functions for that.

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Otter;

namespace OtterPongGame {
    class Program {
        static void Main(string[] args) {
            Game game = new Game("Otter Pong", 700, 700);

            Global.PlayerOne = game.AddSession("P1");
            Global.PlayerTwo = game.AddSession("P2");
            Global.PlayerOne.Controller.AddAxis("Axis1");
            Global.PlayerTwo.Controller.AddAxis("Axis1");
            //First create the WASD Axis
            Global.PlayerOne.Controller.Axis("Axis1").AddAxis(Otter.Axis.CreateWASD());
            //Then create the arrow keys axis.
            Global.PlayerTwo.Controller.Axis("Axis1").AddAxis(Otter.Axis.CreateArrowKeys());


            game.FirstScene = new PongScene();

            game.Start();
        }
    }
}


Also there were some things with your State Machine. You need an enum, not strings.

enum states {
        Shortend,
        Lengthend,
        SpeedBosted,
        SpeedSlowed,
        Normal
    }

Then create the StateMachine like that: public StateMachine<states> paddleSM = new StateMachine<states>();

Now change every paddleSM.ChangeState(state) so that they use the enum instead of a string.
« Last Edit: April 15, 2015, 09:02:06 AM by BitteWenden »

Kyle

  • Administrator
  • Member
  • Posts: 258
    • View Profile
Re: Problem On Pong Video
« Reply #4 on: April 21, 2015, 03:08:13 PM »
Ah yeah some stuff has been changing since the Otter pong video, I really need to do an updated version and double check all of my examples soon!