본문 바로가기
C#

원 처럼 움직이기

by improve 2024. 2. 19.

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;
        }
    }
}

 

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

 

'C#' 카테고리의 다른 글

파일 저장 및 불러오기  (0) 2024.02.20
c# 수업중 내용  (0) 2024.02.19
라벨 이용하기  (0) 2024.02.16
C# 콘솔  (0) 2024.02.13
c# oracle에서 연동, listbox에 보여주기.  (0) 2024.02.08