프로그래밍 언어20 [JAVA] 채팅 서버, 클라이언트 예제 ================== 서버 ============================ public class Server {public static void main(String[] arg){ServerSocket server = null;BufferedReader in = null;try{// 서버 포트번호 셋팅server = new ServerSocket(12345);System.out.println("Server Ready");while(true){// 클라이언트가 보내는 연결요청을 기다린다.Socket s = server.accept();// 클라이언트가 보낸 데이터를 읽는 객체를 생성한다.in = new BufferedReader(new InputStreamReader(s.getInputS.. 프로그래밍 언어/프로그래밍 2016. 10. 2. [JAVA] 스트림 입출력 형식 종류별 스트림 1바이트 입출력 형식 1. 콘솔 출력 FileOutputStream fos = new FileOutputStream(FileDescriptor.out);BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);DataOutputStream dos = new DataOutputStream(bos);dos.write() 입력 FieInputStream fis = new FileInputStream(FileDescriptor.in);BufferedInputStream bis = new BufferedInputStream(fis,1024);DataInputStream dis = new DataInputStream(bis);dis.read() .. 프로그래밍 언어/프로그래밍 2016. 9. 30. 유니티 - 원하는 방향으로 총알 발사 마우스 클릭한 방향으로 총알 발사 Vector2 dir = (Camera.main.ScreenToWorldPoint(Input.mousePosition) - arrow.transform.position); GetComponent().transform.Translate(dir.normalized * bulletSpeed * Time.deltaTime); 프로그래밍 언어/유니티3D 2016. 9. 13. [펌]지정된 좌표에서 마우스포인터로 방향회전 //먼저 계산을 위해 마우스와 게임 오브젝트의 현재의 좌표를 임시로 저장합니다. Vector3 mPosition = Input.mousePosition; //마우스 좌표 저장 Vector3 oPosition = arrow.GetComponent().transform.position; //게임 오브젝트 좌표 저장 //카메라가 앞면에서 뒤로 보고 있기 때문에, 마우스 position의 z축 정보에 //게임 오브젝트와 카메라와의 z축의 차이를 입력시켜줘야 합니다. mPosition.z = oPosition.z - Camera.main.transform.position.z; //화면의 픽셀별로 변화되는 마우스의 좌표를 유니티의 좌표로 변화해 줘야 합니다. //그래야, 위치를 찾아갈 수 있겠습니다. Vector3.. 프로그래밍 언어/유니티3D 2016. 9. 13. [PHP] 배열 사용하기 * 배열이란?데이터들의 연속된 집합. ex 1)$one = 1; $two = 2; $three = 3: 위와 같은 여러개의 데이타를 하나의 배열로 만들 수 있다. * 배열 만들기 ex 2)$arr[0] = 1; $arr[1] = 2; $arr[2] = 3; arr이란 변수 하나에 3개의 데이터 값을 담았다. 여기서 중요한 점은 배열의 시작은 [1]이 아니라 [0]부터 시작한다. 이렇게 만들어진 배열은 for문을 이용해 쉽게 접근할 수 있다. ex 3) 1,2,3 * 연관배열 만들기index대신 key를 사용한다. ex 4) $arr = array('one'=>1, 'two'=>2, 'three'=>3) 위에서 one,two,three는 key이고 1,2,3은 value이다. 이 배열에 접근하려면 $arr.. 프로그래밍 언어/PHP 2016. 7. 15. [유니티] 오브젝트 터치좌표로 이동하기 Update() 함수에 추가 if (isMoveState) { //Vector3 targetPos = transform.position + hitPosition; Vector3 dir = hitPosition - transform.position; Vector3 dirXY = new Vector3(dir.x, dir.y , 0); //Vector3 targetPos = transform.position + (hitPosition - transform.position); Vector3 targetPos = transform.position + dirXY; Vector3 framePos = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Tim.. 프로그래밍 언어/프로그래밍 2016. 6. 17. 유니티 점프 리지디바디로 점프 - 물리적 점프GetComponent().velocity = new Vector2(GetComponent().velocity.x, jump); 리지디바디 사용안하고 점프 - 계산식으로 만든 점프 private Vector3 moveDirection = Vector3.zero; Vector3 targetDirection = (new Vector3(CrossPlatformInputManager.GetAxis("Horizontal") * speed, 0f, CrossPlatformInputManager.GetAxis("Vertical") * speed)); if (targetDirection != Vector3.zero) { moveDirection = targetDirection; move.. 프로그래밍 언어/프로그래밍 2016. 6. 8. 안드로이드 2.0 설치방법 0. 설치환경 운영체제 : Windows XP 자바 : jdk-6u11-windows-i586-p.exe(72.9M) Windows 이클립스 : eclipse-java-ganymede-SR1-win32.zip(85.4M) Windows 안드로이드 : android-sdk-windows-1.0_r2.zip(93.8M) Windows (해당 파일 클릭하면 바로 다운 가능합니다.) 1. 자바 & 안드로이드 설치 java.sun.com 으로 접속 다운로드에서 자바 java SE 클릭 java SE Developement Kit(JDK) Bundle 에서 최신 버전 다운. 자바 설치 - 환경설정 - path : programfile/java/bin; 설치확인 - cmd - javac 출력나오면 설치됨 develo.. 프로그래밍 언어/android 설치 2010. 1. 29. sound 애플리케이션에서 종종 버튼음, 알림 등을 위해 효과음을 사용해야 할 때가 있습니다. 이럴 때 SoundPool 을 사용할 수 있습니다. 01. private SoundPool sound_pool; 02. private int sound_beep; 03. 04. private void initSound() 05. { 06. sound_pool = new SoundPool( 5, AudioManager.STREAM_MUSIC, 0 ); 07. sound_beep = sound_pool.load( getContext(), R.raw.beep, 1 ); 08. } 09. 10. public void playSound() 11. { 12. sound_pool.play( sound_beep, 1f, 1f, 0, 0.. 프로그래밍 언어/android 2010. 1. 28. 이미지 읽어오기 3. Decoder . 이미지 읽어오기 BitmapFactory.Options opts = new BitmapFactory.Options(); Bitmap bm; opts.inJustDecodeBounds = true; //이런식으로 이미지를 읽어 온다. 메모리 픽셀을 허용안함. bm = BitmapFactory.decodeStream(is, null, opts); opts.inJustDecodeBounds = false; // this will request the bm 메모리 픽셀을 허용 opts.inSampleSize = 4; // 1:동일한 사이즈 4: width/height의 1/4 사이즈 bm = BitmapFactory.decodeStream(is, null, opts); . decode a.. 프로그래밍 언어/android 2010. 1. 20. animation 2. AnimationDrawable //Drawble객체를 파생하는 이유는 특정하게 그릴수 있는 객체를 하나 만들어서 .Draw(Canvers)를 //콜하면 Canvers 위에 Drawable 객체를 그려준다. //객체를 한번 생성한후에 그객체를 그냥 Draw함수만 부르면 밑에 드로우 로직이 어떤지는 알 필요 없이 //그려지게 하기 위한 역할을 만들 수 있다. public class ProxyDrawable extends Drawable { ..기타 함수들을 override를 한다. //그려질지 말지를 셋팅을 한다. @Override public Drawable mutate() { if (mProxy != null && !mMutated && super.mutate() == this) { mProxy... 프로그래밍 언어/android 2010. 1. 20. 비트맵 그리기 @Override protected void onDraw(Canvas canvas) { canvas.drawColor(Color.WHITE); Bitmap bm = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bm); c.drawLine(10, 10, 100, 100, new Paint()); canvas.drawBitmap(bm, 10, 10, new Paint()); } 1. 빈 Bitmap을 만든다. (Bitmap의 종류 참조) 2. Bitmap을 인자로 Canvas를 생성한다. 3. 생성된 Canvas를 이용하여 그림을 그린다. 4. Bitmap을 Canvas에 그린다. 프로그래밍 언어/android 2009. 10. 29. 이전 1 2 다음