no image
[고1 게임엔진] 09 - (4)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Forever_Chase : MonoBehaviour { // 유령이 플레이어을 계속 쫓아다닌다. // 목표오브젝트(타겟-boy) Rigidbody2D rb; GameObject targetObject; // 타겟오브젝트를 찾기위한 변수선언 public float speed = 5; // 유령의 이동속도 public string targetObjectName; // 목표오브젝트에 이름 저장 public string showObjectName; // 표시할오브젝트 이름 저장(햄버거) GameObject showObject; // 표시할 오브젝트..
2023.09.18
no image
[고1 프로그래밍] 09 - (3)
import pickle profile3_file = open("profile3.pickle", "wb") profile3 = {"이름":"박명수", "나이":30, "취미":["축구", "골프", "코딩"]} print(profile3) pickle.dump(profile3, profile3_file) profile3_file.close() # import pickle # profile3_file = open("profile3.pickle", "rb") # profile3 = pickle.load(profile3_file) # print(profile3) # profile3_file.close() import pickle with open("profile3.pickle", "rb") as profile..
2023.09.18
no image
[고1 수학] 2학기 1차 지필평가
원과 직선의 위치 관계 원 $x^2+y^2=r^2$에 접하고 기울기가 $m$인 접선의 방정식은 $y=mx±r\sqrt{m^2+1}$ 원 $x^2+y^2=r^2$ 위의 점 $(x₁, y₁)$에서의 접선의 방정식은 $x₁x+y₁y=r^2$ 평행이동 방정식 $f(x, y)=0$이 나타내는 도형을 x축의 방향으로 a만큼, y축의 방향으로 b만큼 평행이동한 도형의 방정식은 $f(x-a, y-b)=0$ 대칭이동 x축 대칭 (x, -y) y축 대칭 (-x, y) 원점 대칭 (-x, -y) 직선 y=x 대칭 (y, x) 집합 집합 기준에 따라 대상을 분명히 정할 수 있을 때, 그 대상들의 모임 원소 집합을 이루는 대상 하나하나 a∈A a가 집합 A의 원소일 때 100 이하의 홀수의 집합을 A라 할 때, A = {1, ..
2023.09.17
no image
[고1 화면구현] 09 - (2)
Consolas font font-weight 900 font-weight 100 Italic Style Oblique Style 현재 크기의 1.5배 크기로 DIVDIVDIV
2023.09.14
no image
[고1 프로그래밍] 09 - (2)
file = open("newfile.txt","w",encoding="utf-8") for i in range(1,11): data = "%d번째 입니다\n" % i file.write(data) # data를 파일객체(file)에 써라 file.close() file = open("newfile.txt","r",encoding="utf-8") line = file.readline() print(line) file.close() file = open("newfile.txt", "r", encoding="utf-8") while True: line = file.readline() if not line: break print(line, end="") file.close() file = open("newfi..
2023.09.13
no image
[고1 게임엔진] 09 - (3)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Forever_Chase : MonoBehaviour { // (유령이) 플레이어를 계속 추적한다(Chase) public float speed = 3; // 유령의 이동속도 public string targetObjectName; // 목표 오브젝트의 이름 저장 // 리지드바디컴포넌트형 변수선언(클래스명 변수명 = new 클래스명()) Rigidbody2D rb; // 게임오브젝트형 변수선언 GameObject targetObject; void Start() { rb = GetComponent(); rb.gravityScale = 0; rb..
2023.09.13
no image
[고1 화면구현] 09 - (1)
CSS3 색 활용 deepskyblue(#00BFFF) brown(#A52A2A) fuchsia(#FF00FF) darkorange(#FF8C00) darkcyan(#UU8B8B) olivedrab(#6B8E23) 텍스트 꾸미기 HTML의 태그만으로 기존의 워드 프로세서와 같이 들여쓰기, 정렬, 공백, 간격 세밀한 텍스트 제어를 할 수 있다 그러나, 스타일 시트는 이를 가능하게 한다 밑줄 없는 네이버 링크
2023.09.12
no image
[고1 게임엔진] 09 - (2)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { // 좌우이동 && 점프(velocity만 사용) // 리지드바디2D형 변수선언 Rigidbody2D rb; [HideInInspector] public float speed = 5; // 좌우이동시 이동 속도 public float jumpPower = 8; // 점프력 float axisH; // 좌우이동 여부 // public 처럼 에디터에서 편집 가능, 하지만 외부스크립트에서는 접근불가(private) [SerializeField] Transform tr; // 트랜스폼 컴..
2023.09.11
no image
[고1 프로그래밍] 09 - (1)
f = open("newfile.txt", "w", encoding="utf-8") for i in range(1, 11): data = "%d번째 줄입니다.\n" %i f.write(data) f.close() # for i in range(1, 11): # data = "%d번째 줄입니다.\n" %i # print(data) # f = open("newfile.txt", "r", encoding="utf-8") # line = f.readline() # print(line) # f.close() # f = open("newfile.txt", "r", encoding="utf-8") # while True: # line = f.readline() # if not line: # break # print(..
2023.09.11
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Forever_Chase : MonoBehaviour
{
    // 유령이 플레이어을 계속 쫓아다닌다.
    // 목표오브젝트(타겟-boy)
    Rigidbody2D rb;
    GameObject targetObject; // 타겟오브젝트를 찾기위한 변수선언

    public float speed = 5;         // 유령의 이동속도
    public string targetObjectName; // 목표오브젝트에 이름 저장
    public string showObjectName;   // 표시할오브젝트 이름 저장(햄버거)

    GameObject showObject; // 표시할 오브젝트를 찾아서 저장할 변수 선언

    void Start()
    {
        // 리지드바디 컴포넌트 가져오기
        rb = GetComponent<Rigidbody2D>();
        // 중력을 0, 충돌후에 회전금지
        rb.gravityScale = 0;
        rb.constraints = RigidbodyConstraints2D.FreezeRotation;

        // 타겟오브젝트 찾기
        targetObject = GameObject.Find(targetObjectName); // 오브젝트의 이름으로 찾는방법

        Time.timeScale = 1;     // 처음부터 시간이 움직이게 처리한다.

        // 유니티 실행시키자마자 햄버거를 지운다. 지우기전에 햄버거를 기억해둔다.
        showObject = GameObject.Find(showObjectName); // 햄버거오브젝트 찾아서 저장
        showObject.SetActive(false); // 플레이시키자마자 햄버거 안보이게(비활성화)
    }

    // 일정한 속도로 유령이 쫓아가게하기 위해서
    void FixedUpdate()
    {
        // 유령이 목표오브젝트의 위치와 방향을 찾는다(벡터-속도: 크기+방향)
        // 지역변수 dir
        Vector2 dir = (targetObject.transform.position - this.transform.position).normalized;
        // 벡터 : 배열객체, 2차원배열(x, y)


        // 유령이 그 방향으로 계속 따라간다
        float vx = dir.x * speed;
        float vy = dir.y * speed;
        rb.velocity = new Vector2(vx, vy);


        // 이동방향에서 좌우반전
        GetComponent<SpriteRenderer>().flipX = (vx < 0);
    }
    void OnCollisionEnter2D(Collision2D collision)
    {
        // 만약 충돌한 것의 이름이 목표오브젝트(boy)라면
        if(collision.gameObject.name == targetObjectName)
        {
            showObject.SetActive(true); // 지운것(=비활성화된것)을 다시 표시

            Time.timeScale = 0; // 시간을 멈춘다=모든 오브젝트의 움직임을 정지해라
        }
    }
}

'----------고1---------- > 게임엔진' 카테고리의 다른 글

[고1 게임엔진] 09 - (6)  (0) 2023.09.25
[고1 게임엔진] 09 - (5)  (2) 2023.09.20
[고1 게임엔진] 09 - (3)  (0) 2023.09.13
[고1 게임엔진] 09 - (2)  (3) 2023.09.11
[고1 게임엔진] 09 - (1)  (0) 2023.09.04
import pickle
profile3_file = open("profile3.pickle", "wb")
profile3 = {"이름":"박명수", "나이":30, "취미":["축구", "골프", "코딩"]}
print(profile3)
pickle.dump(profile3, profile3_file)
profile3_file.close()

# import pickle
# profile3_file = open("profile3.pickle", "rb")
# profile3 = pickle.load(profile3_file)
# print(profile3)
# profile3_file.close()

import pickle
with open("profile3.pickle", "rb") as profile3_file:
    print(pickle.load(profile3_file))
with open("study3.txt", "w", encoding="utf-8") as study3_file:
    print(study3_file.write("파이썬을 열심히 공부하고 있어요."))

with open("study3.txt", "r", encoding="utf-8") as study3_file:
    print(study3_file.read())
class Monster:
    def __init__(self, name):
        self.name = name

    def say(self):
        print(f"나는 {self.name}")

shark = Monster("상어")
shark.say()

wolf = Monster("늑대")
wolf.say()

원과 직선의 위치 관계

원 $x^2+y^2=r^2$에 접하고 기울기가 $m$인 접선의 방정식은
$y=mx±r\sqrt{m^2+1}$

 

원 $x^2+y^2=r^2$ 위의 점 $(x₁, y₁)$에서의 접선의 방정식은
$x₁x+y₁y=r^2$

 

평행이동

방정식 $f(x, y)=0$이 나타내는 도형을
x축의 방향으로 a만큼, y축의 방향으로 b만큼
평행이동한 도형의 방정식은
$f(x-a, y-b)=0$

 

대칭이동

x축 대칭 (x, -y)
y축 대칭 (-x, y)
원점 대칭 (-x, -y)
직선 y=x 대칭 (y, x)

 


 

집합

집합  기준에 따라 대상을 분명히 정할 수 있을 때, 그 대상들의 모임
원소  집합을 이루는 대상 하나하나
a∈A  a가 집합 A의 원소일 때

100 이하의 홀수의 집합을 A라 할 때,
A = {1, 3, 5, ⋯, 99}
A = {x | x는 100 이하의 홀수} (조건 제시법)

벤다이어그램

공집합 ∅  원소가 하나도 없는 집합
부분집합 ⊂  집합 A의 모든 원소가 집합 B에 속할 때
진부분집합  집합 A가 집합 B의 부분집합이고 서로 같지 않을 때 (A⊂B, A≠B)
교집합 ∩  집합 A에도 속하고 집합 B에도 속하는 모든 원소로 이루어진 집합
합집합 ∪  집합 A에 속하거나 집합 B에 속하는 모든 원소로 이루어진 집합
서로소  두 집합 A, B에서 공통인 원소가 하나도 없을 때 (A∩B=∅)
전체집합 U  처음에 주어진 집합
여집합 AC={x | x∈U 그리고 x∉A}  U의 원소 중 A에 속하지 않은 모든 원소로 이루어진 집합
차집합 A-B={x | x∈A 그리고 x∉B}  집합 A에는 속하지만 집합 B에는 속하지 않는 모든 원소로 이루어진 집합
교환법칙 A ∪ B = B ∪ A, A ∩ B = B ∩ A
결합법칙 ( A ∩ B ) ∪ C = A ∪ ( B ∪ C ), ( A ∩ B ) ∩ C = A ∩ ( B ∩ C )
분배법칙 ∩ ( B ∪ C ) = ( A ∩ B ) ∪ ( A ∩ C )
A ∪ ( B C ) = ( A ∪ B ) ∩ ( A ∪ C )
드모르간의 법칙 ( A ∪ B )C = AC ∩ BC
( A ∩ B )C = AC ∪ BC

 


 

명제와 조건

명제 '10은 10이다.'
거짓 '10은 3이다.'
조건 U = {x|x는 10 미만의 수}
'p: x는 10 이하의 소수이다.'
진리집합 P={2, 3, 5, 7}
명제가 아님 '10은 3에 가깝다.'

 

명제의 부정 '10은 10이 아니다. (거짓)'
거짓 '10은 3이 아니다. (참)'
조건 U = {x|x는 10 미만의 수}
'~p: x는 10 이하의 소수가 아니다.'
진리집합 PC={1, 4, 6, 8, 9}

 

 

U = {x|x는 정수}
명제 진리집합 참, 거짓의 판별
모든 x에 대하여 x=10 {10} 거짓
어떤 x에 대하여 x=3 {3}

 

 

  가정 p 결론 q
x=3 이면 x+7=10 이다. (참)
|x|+7=10 이면 x=3 이다. (거짓)
대우 x≠3 이면 x+7≠10 이다. (참)  

 

'x=3   ⇒   x+7=10'
충분조건 P⊂Q x=3
필요조건 Q⊂P x+7=10
필요충분조건 P=Q x=3 x+7=10
<!DOCTYPE html>
<html lang="ko">
    <head>
        <meta charset="utf-8">
        <title>폰트</title>
        <style>
            body {
                font-family: "Times New Roman", serif;
                font-size:large;
            }
            h3 {
                font:italic bold 40px consolas, sans-serif;
            }
        </style>
    </head>
    <body>
        <h3>Consolas font</h3>
        <hr>
        <p style="font-weight:900">font-weight 900</p>
        <p style="font-weight:100">font-weight 100</p>
        <p style="font-style:italic">Italic Style</p>
        <p style="font-style:oblique">Oblique Style</p>
        <p>현재 크기의
            <span style="font-size:1.5em">1.5배</span>
            크기로
        </p>
    </body>
</html>

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>박스모델</title>
        <style>
            body {
                background:rgb(95, 142, 183);
            }
            span {
                background:rgb(25, 202, 134);
            }
            div.box {
                background:yellow;
                border-style:solid;
                border-color:peru;
                margin:40px;
                border-width:20px;
                padding:20px;
                width:200px;
                height:50px;
            }
        </style>
    </head>
    <body>
        <div class="box"><span>DIVDIVDIV</span></div>
    </body>
</html>

'----------고1---------- > 화면구현' 카테고리의 다른 글

[고1 화면구현] 10 - (1)  (0) 2023.10.05
[고1 화면구현] 09 - (5)  (0) 2023.09.26
[고1 화면구현] 09 - (4)  (1) 2023.09.21
[고1 화면구현] 09 - (3)  (0) 2023.09.19
[고1 화면구현] 09 - (1)  (1) 2023.09.12
file = open("newfile.txt","w",encoding="utf-8")
for i in range(1,11):
    data = "%d번째 입니다\n" % i
    file.write(data) # data를 파일객체(file)에 써라
file.close()

file = open("newfile.txt","r",encoding="utf-8")
line = file.readline()
print(line)
file.close()

file = open("newfile.txt", "r", encoding="utf-8")
while True:
    line = file.readline()
    if not line:
        break
    print(line, end="")
file.close()

file = open("newfile.txt", "r", encoding="utf-8")
lines = file.readlines()
for line in lines:
    print(line, end="")
file.close()

file = open("newfile.txt", "r", encoding="utf-8")
data = file.read()
print(data)
file.close()

file = open("newfile.txt", "a", encoding="utf-8")
for i in range(11, 21):
    data = "%d번째 줄입니다.\n" %i
    file.write(data)
file.close()

file2 = open("newfile2.txt", "w", encoding="utf-8")
file2.write("Life is too short, you need python.")
file2.close()

with open("newfile3.txt", "w", encoding="utf-8") as file3:
    file3.write("파이썬 공부 열심히 하면 훌륭한 사람이 될거예요.")
for i in range(1, 51):
    with open(str(i) + "주차.txt", "w", encoding="utf8") as report_file:
        report_file.write("- {0} 주차 주간보고 -".format(i))
        report_file.write("\n부서 : ")
        report_file.write("\n이름 : ")
        report_file.write("\n업무 요약 : ")
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Forever_Chase : MonoBehaviour
{
    // (유령이) 플레이어를 계속 추적한다(Chase)
    
    public float speed = 3;         // 유령의 이동속도
    public string targetObjectName; // 목표 오브젝트의 이름 저장

    // 리지드바디컴포넌트형 변수선언(클래스명 변수명 = new 클래스명())
    Rigidbody2D rb;
    // 게임오브젝트형 변수선언
    GameObject targetObject;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        rb.gravityScale = 0;
        rb.constraints = RigidbodyConstraints2D.FreezeRotation;

        // 목표 오브젝트를 찾는다.
        targetObject = GameObject.Find(targetObjectName);
    }

    void FixedUpdate() //일정한 속도로 진행
    {
        // 목표 오브젝트의 방향을 조사한다. 방향을 조사해서
        Vector2 dir = (targetObject.transform.position - this.transform.position).normalized; // 벡터형 변수

        // 그 방향으로 (계속) 이동한다.
        float vx = dir.x * speed;
        float vy = dir.y * speed;

        rb.velocity = new Vector2(vx, vy);

        // 유령이 이동방향을 바꿀때 반전하기
        this.GetComponent<SpriteRenderer>().flipX = (vx < 0);
    }
}

'----------고1---------- > 게임엔진' 카테고리의 다른 글

[고1 게임엔진] 09 - (5)  (2) 2023.09.20
[고1 게임엔진] 09 - (4)  (0) 2023.09.18
[고1 게임엔진] 09 - (2)  (3) 2023.09.11
[고1 게임엔진] 09 - (1)  (0) 2023.09.04
[고1 게임엔진] 08 - (1)  (0) 2023.08.30
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>CSS 색 활용</title>
        <style>
            div {
                margin-left:30px;
                margin-right:30px;
                margin-bottom:10px;
                color:white;    /* 모든 <div> 글자 색은 white */
            }
        </style>
    </head>
    <body>
        <h3>CSS3 색 활용</h3>
        <hr>
        <div style="background-color:deepskyblue">deepskyblue(#00BFFF)</div>
        <div style="background-color:brown">brown(#A52A2A)</div>
        <div style="background-color:fuchsia">fuchsia(#FF00FF)</div>
        <div style="background-color:darkorange">darkorange(#FF8C00)</div>
        <div style="background-color:darkcyan">darkcyan(#UU8B8B)</div>
        <div style="background-color:olivedrab">olivedrab(#6B8E23)</div>
    </body>
</html>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>텍스트 꾸미기</title>
        <style>
            h3 {
                text-align: right; /* 오른쪽 정렬 */
            }
            span {
                text-decoration: line-through; /* 중간 줄 */
            }
            strong {
                text-decoration: overline; /* 윗 줄 */
            }
            .p1 {
                text-indent: 3em;    /* 3글자 들여쓰기 */
                text-align: justify; /* 양쪽 정렬 */
            }
            .p2 {
                text-indent: 1em;    /* 1글자 들여쓰기 */
                text-align: center; /* 중앙 정렬 */
            }
        </style>
    </head>
    <body>
        <h3>텍스트 꾸미기</h3>
        <hr>
        <p class="p1">HTML의 태그만으로 기존의 워드 프로세서와 같이 들여쓰기,
            정렬, 공백, 간격 세밀한 <span>텍스트 제어</span>를 할 수 있다</p>
        <p class="p2">그러나, <strong>스타일 시트</strong>는 이를 가능하게 한다</p>
        <a href="https://www.naver.com" style="text-decoration:none;">
            밑줄 없는 네이버 링크</a>
    </body>         
</html>

'----------고1---------- > 화면구현' 카테고리의 다른 글

[고1 화면구현] 10 - (1)  (0) 2023.10.05
[고1 화면구현] 09 - (5)  (0) 2023.09.26
[고1 화면구현] 09 - (4)  (1) 2023.09.21
[고1 화면구현] 09 - (3)  (0) 2023.09.19
[고1 화면구현] 09 - (2)  (0) 2023.09.14
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    // 좌우이동 && 점프(velocity만 사용)

    // 리지드바디2D형 변수선언
    Rigidbody2D rb;

    [HideInInspector]
    public float speed = 5;     // 좌우이동시 이동 속도
    public float jumpPower = 8; // 점프력

    float axisH;    // 좌우이동 여부

    // public 처럼 에디터에서 편집 가능, 하지만 외부스크립트에서는 접근불가(private)
    [SerializeField] Transform tr;       // 트랜스폼 컴포넌트 변수 선언
    [SerializeField] float radius;       // 반지름
    [SerializeField] LayerMask isLayer;  // 레이어마스크형 변수선언

    bool isGround;      // 레이어에 발밑이 닿았는지 여부

    void Start()
    {
        // 리지드바디2D 컴포넌트 가져오기
        rb = GetComponent<Rigidbody2D>();
        // 충돌후 회전금지
        rb.constraints = RigidbodyConstraints2D.FreezeRotation;
    }

    void Update()
    {
        // 좌우이동 감지
        axisH = Input.GetAxisRaw("Horizontal"); // +1, -1, 0 세값중 하나
        // 점프여부
        isGround = Physics2D.OverlapCircle(tr.position, radius, isLayer);   // true or false
        if(isGround && Input.GetKeyDown("space"))
        {
            // 점프하기
            rb.velocity = Vector2.up * jumpPower;
        }
        else if(isGround==false && Input.GetKeyDown("space"))
        {
            rb.velocity = Vector2.zero; // (0, 0)
        }
    }

    void FixedUpdate()
    {
        // 좌우이동하기
        rb.velocity = new Vector2(axisH * speed, rb.velocity.y);

        // 좌우반전하기
        if(axisH != 0)  // +1 또는 -1이면
        {
            transform.localScale = new Vector2(axisH, 1);
        }
    }
}

'----------고1---------- > 게임엔진' 카테고리의 다른 글

[고1 게임엔진] 09 - (4)  (0) 2023.09.18
[고1 게임엔진] 09 - (3)  (0) 2023.09.13
[고1 게임엔진] 09 - (1)  (0) 2023.09.04
[고1 게임엔진] 08 - (1)  (0) 2023.08.30
[고1 게임엔진] 08 - (3)  (0) 2023.08.30
f = open("newfile.txt", "w", encoding="utf-8")
for i in range(1, 11):
    data = "%d번째 줄입니다.\n" %i
    f.write(data)
f.close()

# for i in range(1, 11):
#     data = "%d번째 줄입니다.\n" %i
#     print(data)

# f = open("newfile.txt", "r", encoding="utf-8")
# line = f.readline()
# print(line)
# f.close()

# f = open("newfile.txt", "r", encoding="utf-8")
# while True:
#     line = f.readline()
#     if not line:
#         break
#     print(line, end="")
# f.close()

f = open("newfile.txt", "r", encoding="utf-8")
lines = f.readlines()