C#

원 처럼 움직이기

improve 2024. 2. 19. 16:23

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Systehttp://m.Threading.Tasks;
using Systehttp://m.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        int y = 40;
        int gak = 10;

        public Form1()
        {
            InitializeComponent();

            timer1.Interval = 500;
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Console.WriteLine(Math.PI);
            Console.WriteLine(Math.Cos((gak * Math.PI)/180) * 100);
            Console.WriteLine(Math.Sin((gak * Math.PI)/180) * 100);

            int x = 200 + (int)(Math.Cos((gak * Math.PI) / 180) * 150);
            int y = 200 + (int)(Math.Sin((gak * Math.PI) / 180) * 150);

            Console.WriteLine("출력");
            button1.Location = new Point(10, y);
            y += 40;
        }
    }
}

 

이렇게 하면 원처럼 돌아간다.