-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
World Generation, Chat, Optimizations and stuff
- Loading branch information
Showing
32 changed files
with
723 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
# Raylib Voxel Engine | ||
# IsleForge | ||
![Image](https://i.imgur.com/mgC5tN3.png) | ||
[![Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/tZthSbpUcV) | ||
|
||
Voxel Engine made in C using Raylib. | ||
Requires [Raylib](https://github.com/raysan5/raylib) and [ENet](https://github.com/zpl-c/enet) | ||
Open-Source Voxel Game made in C using Raylib. | ||
|
||
*Multiplayer is not fully implemented yet so the server code will come later. | ||
*Multiplayer is not fully implemented yet so the server code will come later. | ||
|
||
## Dependencies | ||
|
||
| Dependency | Version | | ||
|---------------|---------| | ||
| Raylib | 4.0 | | ||
| Zpl-c/ENet | 2.3.0 | | ||
| FastNoiseLite | - | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* Copyright (c) 2021 Sirvoid | ||
* | ||
* This software is released under the MIT License. | ||
* https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
#include <string.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "raylib.h" | ||
#include "raygui.h" | ||
#include "chat.h" | ||
#include "player.h" | ||
#include "networkhandler.h" | ||
#include "packet.h" | ||
#include "screens.h" | ||
|
||
char* chatLines[64]; | ||
int currentLine = 0; | ||
|
||
void Chat_AddLine(char *line) { | ||
if(chatLines[currentLine]) MemFree(chatLines[currentLine]); | ||
chatLines[currentLine++] = line; | ||
if(currentLine >= 64) { | ||
currentLine = 0; | ||
} | ||
} | ||
|
||
|
||
char Chat_input[64] = ""; | ||
bool Chat_editMode = false; | ||
bool Chat_open = false; | ||
|
||
void Chat_Draw(Vector2 offset, Color uiColor) { | ||
|
||
if(!Network_connectedToServer) return; | ||
|
||
int chatWidth = 352; | ||
int fontSize = 10; | ||
|
||
//Draw Background | ||
if(Chat_editMode) DrawRectangle(offset.x, offset.y - 184 + 46, chatWidth, 184, uiColor); | ||
|
||
//Draw Lines | ||
int lineAdded = 0; | ||
|
||
int index = currentLine; | ||
while(lineAdded < 13) { | ||
if(chatLines[index]) { | ||
int textLength = TextLength(chatLines[index]); | ||
int startPos = 0; | ||
char *drawLines[3]; | ||
int drawLinesCnt = 0; | ||
for(int i = 0; i < textLength; i++) { | ||
const char* sub = TextSubtext(chatLines[index], startPos, i - startPos + 1); | ||
int textWidth = MeasureText(sub, fontSize); | ||
if(textWidth >= chatWidth - fontSize - 4 || i == textLength - 1) { | ||
drawLines[drawLinesCnt] = MemAlloc(64); | ||
TextCopy(drawLines[drawLinesCnt], sub); | ||
drawLinesCnt++; | ||
startPos = i; | ||
} | ||
} | ||
for(int i = drawLinesCnt - 1; i >= 0; i--) { | ||
if(!drawLines[i]) continue; | ||
DrawText(drawLines[i], offset.x + 4, offset.y - lineAdded * fontSize, fontSize, WHITE); | ||
lineAdded++; | ||
} | ||
} | ||
|
||
index--; | ||
if(index < 0) index = 63; | ||
if(index == currentLine) break; | ||
} | ||
|
||
//Chat input | ||
if(Chat_editMode) GuiTextBox((Rectangle) { offset.x, offset.y + 22, chatWidth, 24 }, Chat_input, 64, Chat_editMode); | ||
|
||
if(IsKeyPressed(KEY_ENTER)) { | ||
if(Chat_open) { | ||
char *message = MemAlloc(64); | ||
for(int i = 0; i < 64; i++) { | ||
message[i] = Chat_input[i]; | ||
Chat_input[i] = '\0'; | ||
} | ||
Network_Send(Packet_SendMessage(message)); | ||
DisableCursor(); | ||
Chat_open = false; | ||
Screen_cursorEnabled = false; | ||
} | ||
} | ||
|
||
if(Chat_open) { | ||
Chat_editMode = true; | ||
} else { | ||
Chat_editMode = false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright (c) 2021 Sirvoid | ||
* | ||
* This software is released under the MIT License. | ||
* https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
#ifndef G_CHAT_H | ||
#define G_CHAT_H | ||
|
||
extern bool Chat_open; | ||
|
||
void Chat_AddLine(char *line); | ||
void Chat_Draw(Vector2 offset, Color uiColor); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.