코딩 95

[리브레캐드] 설치하기

리브레캐드는 2D 캐드로 오픈소스로 만들어져 있어서 무료로 이용할 수 있습니다. 레이저커팅기나 간단한 cad 설계에 잘 사용 됩니다. 보통 레이저커팅기는 dxf 파일을 이용하는데 리브레캐드를 이용하면 일반 유저의 dxf 파일 이용이 자유롭습니다. 1. 다운로드 받기 https://librecad.org/ 사이트에 접속합니다. 저는 윈도우즈 OS라서 from GitHub를 클릭합니다. 아래쪽에 Assets에서 LibreCAD-Installer-2.2.02.exe를 클릭하여 다운 받습니다. 설치하고 환경

[파이썬] chatgpt에서 받은 응답의 데이터형 확인

chatgpt에서 받은 응답을 sample_json.json 이라고 파일로 저장해두고 시퀀스, 컬렉션을 확인해 봅니다. chatgpt에서 받은 응답은 json 형식입니다. * sample_json.json { "id": "cBatnZhKsLxtcoq9aMOYvkmOlJUNUUj-8hpWh0", "object": "chat.completion", "created": 5691337009, "model": "gpt-3.5-turbo-0613", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "\uc7a1\ud1a0\uc774\ub780 \uac78 \ube0c\ub79c\ub4dc." }, "logprobs": null, "fi..

programming/python 2024.03.11

[유니티 2D] 아이템 원하는 위치 놓기(2차원 배열 이용)

item 프리팹 파일을 만듭니다. 놓여질 위치의 x, y 좌표를 적어 둡니다. x, y 좌표를 2차원 배열로 만듭니다. * ItemController.cs … public class ItemController : MonoBehaviour { public GameObject itemPrefab; public float span = 2.0f; float temp = 0.0f; int count = 0; int[ , ] map = new int[10, 2] { { 30, 15 }, { 52, 24 }, { 70, 35 }, { 132, 34 }, { 115, 58 }, { 179 ,63 }, { 162, 89 }, { 225, 93 }, { 180, 123 }, { 132, 93 } }; void Start(..

유니티 2024.03.10

[유니티 2D] 칼 정해진 각도로 회전하기

유니티2D에서는 Transform의 Rotation의 z축이 회전입니다. 정해진 각도로 움직이려면 eulerAngles 값을 변경해야 합니다. * SwordController.cs void Update() { if (Input.GetKeyDown(KeyCode.A)) { gameObject.transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0f); } if (Input.GetKeyDown(KeyCode.B)) { gameObject.transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 90f); } if..

유니티 2024.03.10

[유니티 2D] 기어 회전하기

유니티2D에서는 z축이 회전입니다. Transform.Rotate를 이용해서 z의 값을 바꿔줍니다. * GearController.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class GearController : MonoBehaviour { void Start() { } void Update() { // 회전방향을 바꾸려면 100f를 -100f로 바꾸면 됩니다. transform.Rotate(new Vector3(0, 0, 100f * Time.deltaTime)); // transform.Rotate(Vector3.forward * 100f * Time.deltaTime); } }

유니티 2024.03.10

[유니티 2D] 플레이어 따라오기

게임오브젝트가 플레이어를 따라오도록 합니다. * Rotate.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class Rotate : MonoBehaviour { public GameObject target; private void OnCollisionEnter2D(Collision2D collision) { if(collision.gameObject.tag == "Bullet") { transform.position = new Vector3( transform.position.x + 1, 0, 0 ); } } void Start() { } void Update() { Vector3 dir =..

유니티 2024.03.10

[유니티 2D] 미로 - 생명

Hierarcy창에서 UI > Text 선택하고, 게임오브젝트의 이름을 HP로 변경한다. HP 게임오브젝트의 Text>Text를 원하는 값으로 수정합니다. Project > Assets 폴더에 Ghost.prefab 게임오브젝트의 Tag값을 Ghost로 줍니다. Project > Assets 폴더에서 Hp.cs라는 이름의 C#스크립트를 만듭니다. Tag값으로 Ghost란 이름을 가진 게임오브젝트와 만나면 hp가 1점 깍입니다. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class Hp : Mon..

유니티 2024.03.10

[유니티 2D] 미로 - Bullet(총알) 만들기

Hierarchy창에서 + 아이콘을 클릭하고 2D Object > Sprites > Circle을 선택합니다. 게임오브젝트의 이름을 Bullet으로 바꿉니다. 총알이 1초 후에 사라지게 하기 위해서 C# 코드를 만듭니다. BulletDestroy.cs C# 코드의 Start() 함수에 Destroy 로직을 사용합니다. * BulletDestroy.cs … public class BulletDestroy : MonoBehaviour { void Start() { Destroy(gameObject, 1); } void Update() { } } Bullet 게임오브젝트에 BulletDestroy.cs C# 코드를 연결합니다. Hierachy창의 Bullet 게임오브젝트을 왼쪽 마우스버튼으로 끌어다가 Asse..

유니티 2024.03.10

[유니티 2D] 미로 - 유령이 플레이어 바라보고 쫓아오기

Assets 폴더의 유령 이미지를 Scene 창에 끌어다 놓습니다. Assets 폴더의 유령 이미지를 Scene 창에 끌어다 놓습니다. Ghost 게임오브젝트가 car 게임오브젝트 쪽으로 움직입니다. Rotate.cs C# 코드를 작성하고 Ghost 게임오브젝트에 연결 시킵니다. * Rotate.cs … public class Rotate : MonoBehaviour { // 전역변수 public GameObject target; void Start() { } void Update() { transform.position = Vector3.MoveTowards(transform.position, target1.transform.position, 0.01f); transform.rotation = Quat..

유니티 2024.03.10