fix Tetris onkeydown
							parent
							
								
									3245377683
								
							
						
					
					
						commit
						975286302c
					
				|  | @ -114,6 +114,7 @@ fn main() { | ||||||
| 			window_user_ptr: game  | 			window_user_ptr: game  | ||||||
| 		}) | 		}) | ||||||
| 	}  | 	}  | ||||||
|  | 	game.gg.window.set_user_ptr(game) // TODO remove this when `window_user_ptr:` works 
 | ||||||
| 	game.init_game() | 	game.init_game() | ||||||
| 	game.gg.window.onkeydown(key_down) | 	game.gg.window.onkeydown(key_down) | ||||||
| 	go game.run() // Run the game loop in a new thread
 | 	go game.run() // Run the game loop in a new thread
 | ||||||
|  |  | ||||||
|  | @ -150,27 +150,20 @@ pub fn mouse_move(w voidptr, x, y f64) { | ||||||
| 	// #printf("%f : %f => %d \n", x,y);
 | 	// #printf("%f : %f => %d \n", x,y);
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // pub fn create_window(title string, w, h int) * Window {
 |  | ||||||
| pub fn window_hint(key, val int) { | pub fn window_hint(key, val int) { | ||||||
| 	C.glfwWindowHint(key, val) | 	C.glfwWindowHint(key, val) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn create_window(c WinCfg) *Window { | pub fn create_window(c WinCfg) *Window { | ||||||
| 	// TODO why i need this in stdlib? extern?
 |  | ||||||
| 	// # if (!gconst_init)   {  init_consts(); gconst_init = 1; }
 |  | ||||||
| 	// ChatsRepo
 |  | ||||||
| 	if c.borderless { | 	if c.borderless { | ||||||
| 		window_hint(GLFW_RESIZABLE, 0) | 		window_hint(GLFW_RESIZABLE, 0) | ||||||
| 		window_hint(GLFW_DECORATED, 0) | 		window_hint(GLFW_DECORATED, 0) | ||||||
| 	} | 	} | ||||||
| 	if c.always_on_top { | 	if c.always_on_top { | ||||||
| 		window_hint(GLFW_FLOATING, 1)  | 		window_hint(GLFW_FLOATING, 1)  | ||||||
|   | 	}  | ||||||
| }  |  | ||||||
| 	cwindow := C.glfwCreateWindow(c.width, c.height, c.title.str, 0, 0) | 	cwindow := C.glfwCreateWindow(c.width, c.height, c.title.str, 0, 0) | ||||||
| 	# if (!cwindow) | 	if isnil(cwindow) {  | ||||||
| 	// if cwindow == 0
 |  | ||||||
| 	{ |  | ||||||
| 		println('failed to credate glfw  window') | 		println('failed to credate glfw  window') | ||||||
| 		C.glfwTerminate() | 		C.glfwTerminate() | ||||||
| 	} | 	} | ||||||
|  | @ -184,13 +177,6 @@ pub fn create_window(c WinCfg) *Window { | ||||||
| 		data: cwindow, | 		data: cwindow, | ||||||
| 		title: c.title, | 		title: c.title, | ||||||
| 	} | 	} | ||||||
| 	// user_ptr: ptr,
 |  | ||||||
| 	// repo: repo,
 |  | ||||||
| 	// for !C.glfwWindowShouldClose(cwindow) {
 |  | ||||||
| 	// C.glfwPollEvents()
 |  | ||||||
| 	// wait_events()
 |  | ||||||
| 	// }
 |  | ||||||
| 	// C.glfwTerminate()
 |  | ||||||
| 	return window | 	return window | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue