Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace _01_30_2019
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- class Ship
- {
- private double ship_posX; // position X on map
- private double ship_posY; // position Y on map
- private int ship_heading; // current heading
- private int ship_speed_max; // max speed of a ship
- private int ship_current_speed; // current speed of a ship
- private string ship_class; // surface or submarine
- private string ship_foe; // friend or enemy?
- private string is_controllable; // is controllable by player?
- private int depth; // current depth of a submarine (if a submarine)
- public void move(int heading, int speed)
- {
- if (heading == 0) ship_posY -= speed; // ship is heading NORTH
- if (heading == 45) // ship is heading NORTH-EAST
- {
- ship_posX += speed;
- ship_posY -= speed;
- }
- if (heading == 90) ship_posX += speed; // ship is heading EAST
- if (heading == 135) // ship is heading SOUTH-EAST
- {
- ship_posX += speed;
- ship_posY += speed;
- }
- if (heading == 180) ship_posY += speed; // ship is heading SOUTH
- if (heading == 225) // ship is heading SOUTH-WEST
- {
- ship_posX -= speed;
- ship_posY += speed;
- }
- if (heading == 270) ship_posX -= speed; // ship is heading WEST
- if (heading == 315) // ship is heading NORTH-WEST
- {
- ship_posX -= speed;
- ship_posY -= speed;
- }
- }
- public void create_ship(double posx, double posy)
- {
- ship_posX = posx;
- ship_posY = posy;
- // only a few parameters for now. Later will be name, speed_max, class, friend or foe and more
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- // forms load == game starts
- Ship[] submarine = new Ship[100];
- submarine[0].create_ship(140, 200); // create first ship with only two parameters: position X and Y on future map
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- submarine[0].move(90, 15); // ERROR: compiler shows "The name 'submarine' does not exist in the current context
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement