diff harelet.c @ 8:c60e4315cb7e

Automated Vimcurial commmit
author VilyaemKenyaz
date Tue, 12 Sep 2023 06:46:45 -0400
parents 1bb981516d87
children 4eb02dffc00f
line wrap: on
line diff
--- a/harelet.c	Sat Sep 09 17:11:20 2023 -0400
+++ b/harelet.c	Tue Sep 12 06:46:45 2023 -0400
@@ -7,6 +7,7 @@
 #include <stdio.h> 
 #include <stdlib.h>
 #include <string.h>
+
 #include "basedfilelib.h"
 
 #ifdef __linux__
@@ -31,8 +32,8 @@
 
 point points[MAXPOINT];
 
-unsigned int X = 0;
-unsigned int Y = 0;
+unsigned int X = 100;
+unsigned int Y = 100;
 unsigned int step = 5;
 unsigned int down = 0;
 unsigned int numpoints = 0;
@@ -43,31 +44,15 @@
  * Author - William King
  * Date - Sep 08 2023
  * *******************************************/
-void Render(){
+void Render(){	
 	clrscr();
-	gotoxy(0,0);
+	gotoxy(0,30);
 	puts("HARELET A CAD PROGRAM BY VILYAEM KENYAZ, PEEP SOFTWARE 2023");
 	printf("Number of Points: %d X: %d Y: %d STEPSIZE: %d DWN?: %d\n",numpoints,X,Y,step,down);
 
 	//Render points
 	for(int i = 0;i != MAXPOINT;i++){
-		gotoxy(0,10);
-		/*
-		//Move X
-		for(int j = 0;j != points[i].X;j++){
-
-			printf("");
-
-		}
-
-		//Move Y
-		for(int k = 0;k != points[i].Y;k++){
-
-			puts("");
-
-
-		}
-		*/
+		gotoxy(0,50);
 
 		gotoxy(points[i].X,points[i].Y);
 
@@ -82,16 +67,6 @@
 	}
 
 	//Render cursor
-	/*
-	DocTop();
-	for(int i = 0;i != X;i++){
-		printf("");
-
-	}
-	for(int i = 0;i != Y;i++){
-		puts("");
-	}
-	*/
 
 	gotoxy(X,Y);
 
@@ -109,6 +84,7 @@
 void Compile(){
 	char * filename;
 	char * file;
+	char buffer[sizeof(int)*8+1];
 	int choice;
 
 	puts("Select your format\n1. RAW GCODE");
@@ -127,11 +103,14 @@
 			//Compose
 			char * instruction;
 			strcat(instruction,"G0 X");
-			strcat(instruction,itoa(points[i].X));
+			itoa(points[i].X,buffer);
+			strcat(instruction,buffer);
 			strcat(instruction," Y");
-			strcat(instruction,itoa(points[i].Y));
+			itoa(points[i].Y,buffer);
+			strcat(instruction,buffer);
 			strcat(instruction," Z");
-			strcat(instruction,itoa(DEEPNESS));
+			itoa(DEEPNESS,buffer);
+			strcat(instruction,buffer);
 			//Write to string
 			strcat(file,instruction);
 		}
@@ -152,46 +131,37 @@
  * *******************************************/
 void main(int argc, char* argv[]){
 	while(1){
-	Render();
-	scanf("%c",&action);
-	switch(action){
-		case 'a':		points[numpoints].X = X;
-					points[numpoints].Y = Y;
-					points[numpoints].down = down;
-					numpoints++;
-					break;
-		case 'h': 
+		Render();
+		scanf("%c",&action);
+		switch(action){
+			case 'a':		points[numpoints].X = X;
+						points[numpoints].Y = Y;
+						points[numpoints].down = down;
+						numpoints++;
+						break;
+			case 'h': 
 
-					if(X < 200 - step){
-					X += step;
-					}
-					break;
-		case 'j': 
-					if(X > step){
-					Y += step;
-					}
-					break;
-		case 'k': 
-					if(Y < 0){
-					Y -= step;
-					}
-					break;
-		case 'l': 
-					if(Y > 200){
-					X -= step;
-					}
-					break;
+						X += step;
+						break;
+			case 'j': 
+						Y += step;
+						break;
+			case 'k': 
+						Y -= step;
+						break;
+			case 'l': 
+						X -= step;
+						break;
+			case 's':		
+						puts("Enter new step:");
+						scanf("%d",&step);
+						break;
 
-		case 's':		
-					puts("Enter new step:");
-					scanf("%d",&step);
-					break;
-
-		case 'c':		Compile();
-					break;
-		default:
-					break;
-	}
+			case 'c':		Compile();
+						break;
+			default:
+						break;
+		}
 	}
 
 	exit(0);