Commit 20c21c92 authored by Guillaume Lozenguez's avatar Guillaume Lozenguez

blanc

parent 9b1bf537
# System
.vscode
# source:
*.pyc
*.o
project(blancray LANGUAGES C)
cmake_minimum_required(VERSION 3.10)
# Activate C99 standard:
SET(CMAKE_C_COMPILER "gcc" )
SET(CMAKE_C_FLAGS "-std=c99" )
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-Wall")
# project configuration :
include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/c-src )
# Local dependency: (RayLib) :
include_directories( ${PROJECT_SOURCE_DIR}/lib/include )
link_directories( ${PROJECT_SOURCE_DIR}/lib )
add_executable(nw-viewer c-src/main-viewer.c c-src/networld.c)
target_link_libraries(nw-viewer raylib pthread dl rt X11 m)
include ../config
all: hello viewer
hello: main-hello.o
$(CC) -o ../nw-$@ $^ $(LIBS)
viewer: main-viewer.o networld.o
$(CC) -o ../nw-$@ $^ $(LIBS)
%.o: %.c
$(CC) -c $< $(CFLAGS)
config:
rm config
"OS= `uname`" >> config
clean:
rm -rf *.o
/*******************************************************************************************
*
* NetWorld basic viewer
* Copyright (c) 2020-2020 Guillaume Lozenguez
*
********************************************************************************************/
#include "networld.h"
#include "raylib.h"
#include <stdlib.h>
#include <stdio.h>
// Program attributes
//-------------------
const int screenWidth = 800;
const int screenHeight = 450;
const int targetFPS = 60;
void game_update(NetWorld * world);
void game_draw(NetWorld * world);
// Game attributes
//-----------------
bool game_end;
int main(int nbArg, char ** arg)
{
// Game Initialization
//--------------------
game_end= false;
NetWorld * world= NetWorld_new(3);
NetWorld_initNodePosition( world, 0, 10.4, 12.8 );
NetWorld_initNodePosition( world, 1, 110.4, 52.8 );
NetWorld_initNodePosition( world, 2, 384.5, 422.2 );
// Raylib Initialization
//----------------------
InitWindow(screenWidth, screenHeight, "NetWorld basic viewer");
SetTargetFPS(targetFPS);
// Some verificcations
//--------------------
puts("world variable:");
NetWorld_print(world);
puts("world expected:\n[10.4, 12.8]\n[110.4, 52.8]\n[384.5, 422.2]");
// Main game loop
while (!game_end && !WindowShouldClose()) // Detect window close button or ESC key
{
game_update(world);
game_draw(world);
}
// proper closing
//---------------
NetWorld_delete(world);
CloseWindow(); // Close window and OpenGL context
return 0;
}
void game_update(NetWorld * world)
{
}
void game_draw(NetWorld * world)
{
BeginDrawing();
ClearBackground(RAYWHITE);
for(int i= 0 ; i < world->size ; ++i )
{
Vector2 nodePosition= { world->nodes[i].x, world->nodes[i].y };
DrawCircleV(nodePosition, 24, MAROON);
}
EndDrawing();
}
#include "networld.h"
#include <stdio.h>
#include <stdlib.h>
// Constructor / Destructor
NetWorld * NetWorld_new(int size)
{
NetWorld * p = malloc( sizeof(NetWorld) );
p->size= size;
p->nodes= malloc( p->size * sizeof(Node) );
return p;
}
void NetWorld_delete(NetWorld * self)
{
free( self->nodes );
free( self );
}
// Initialization
void NetWorld_initNodePosition(
NetWorld * self, int iNode,
double x, double y)
{
self->nodes[iNode].x= x;
self->nodes[iNode].y= y;
}
// To String
void NetWorld_print(NetWorld * self)
{
for(int i= 0 ; i < self->size ; ++i )
printf("[%lf, %lf]\n", self->nodes[i].x, self->nodes[i].y);
}
#ifndef NETWORLD_H
#define NETWORLD_H
struct Str_Node {
double x, y;
};
typedef struct Str_Node Node;
struct Str_NetWorld {
int size;
Node * nodes;
};
typedef struct Str_NetWorld NetWorld;
// Constructor / Destructor
NetWorld * NetWorld_new(int aSize);
void NetWorld_delete(NetWorld * self);
// Initialization
void NetWorld_initNodePosition(NetWorld * self, int iNode, double x, double y); // position must be an float[size][2] array...
// To String
void NetWorld_print(NetWorld * self);
#endif //NETWORLD_H
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
File added
libraylib.so.351
\ No newline at end of file
libraylib.so.3.5.0
\ No newline at end of file
import os
# set the path before raylib is imported.
os.environ["RAYLIB_BIN_PATH"] = "."
from raylibpy import *
def main():
init_window(800, 450, "raylib [core] example - basic window")
set_target_fps(60)
while not window_should_close():
begin_drawing()
clear_background(RAYWHITE)
draw_text("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)
end_drawing()
close_window()
if __name__ == '__main__':
main()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment