资源描述:
《海龟做图代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include"graphics.h"#include"math.h"#include"stdio.h"#include"conio.h"#include"bios.h"#include"dos.h"#include"io.h"charkey_state[128],key_pressed[128];voidinterruptfar(*OldInt9Handler)();enummodes{AUTO,HIGH};enumbool{FALSE=0,TRUE=1};#defineMODEenummodes#
2、defineBOOLenumbool#defineK_ENTER0x1c#defineK_DOWN0x50#defineK_UP0x48#defineK_SPACE0x39#defineK_ESC0x01#defineK_C0x2e#defineK_A0x1e#defineK_X0x2d#defineUP0#defineDOWN1#definePI3.1415#defineMODE_KEY0#defineMODE_CMD1#defineMAX_CMD_NUM15/*Instructiondefine*/
3、#defineEXIT0#defineCHM1#definePU2#definePD3#defineCHC4#defineCHHT5#defineADTH6#defineFW7#defineBW8#defineCLR9#defineCHP10enumhlpmsg{ALL_CMD,IN_ERROR,PU_OK,PD_OK,CHC_OK,CHP_OK,CHM_OK, FW_OK,BW_OK,CHHT_OK,ADTH_OK,CLR_OK,M_KEY,IN_COLOR,
4、IN_POS,IN_HEAD,IN_STEPS};#defineHLPMSGenumhlpmsgtypedefintpenState;typedefstruct{floatv,h;}aPoint;typedefstruct{ floatheading; penState pen; int color; aPoint Pos;}newTurtle;newTurtleturtle;charGMODE=MODE_CMD;charCmdWords[MAX_CMD_NUM][4]={
5、 {'E','X','I','T'},{'C','H','M',''}, {'P','U','',''},{'P','D','',''}, {'C','H','C',''},{'C','H','H','T'}, {'A','D','T','H'},{'F','W','',''}, {'B','W','',''},{'C','L','R',''},
6、 {'C','H','P',''}, };charCmdTmp[4];unsignedcharNumTmp[4];unsignedcharNumTmp1[4];typedefstructnode{ intcolor; intx1,x2,y1,y2;}NODE;/*---------------------------------------*//*otherfunctions*/voidOpenSecCmdWnd(){ setcolor(2); r
7、ectangle(510,250,595,275); while(bioskey(1)==0) { setcolor(2); line(513,270,518,270); setcolor(0); line(513,270,518,270); } window(66,17,66,17);}voidCloseSecCmdWnd(){ setfillstyle(SOLID_FILL,0); bar(511,250,595,275);}i
8、ntCvt4CToInt(inti){ if(i==0) returnNumTmp[0]+NumTmp[1]*10+NumTmp[2]*100+NumTmp[3]*1000-53328; else returnNumTmp1[0]+NumTmp1[1]*10+NumTmp1[2]*100+NumTmp1[3]*1000-53328;}intGetAn4BInterger(){ inti,j; unio