From 87a39702228cd309a5f690102980c2b9a6bee426 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 18:06:26 +0200 Subject: Move android_native_app_glue to folder --- src/external/android/native_app_glue/Android.mk | 10 + src/external/android/native_app_glue/NOTICE | 13 + .../native_app_glue/android_native_app_glue.c | 441 +++++++++++++++++++++ .../native_app_glue/android_native_app_glue.h | 349 ++++++++++++++++ src/external/android_native_app_glue.h | 349 ---------------- 5 files changed, 813 insertions(+), 349 deletions(-) create mode 100644 src/external/android/native_app_glue/Android.mk create mode 100644 src/external/android/native_app_glue/NOTICE create mode 100644 src/external/android/native_app_glue/android_native_app_glue.c create mode 100644 src/external/android/native_app_glue/android_native_app_glue.h delete mode 100644 src/external/android_native_app_glue.h diff --git a/src/external/android/native_app_glue/Android.mk b/src/external/android/native_app_glue/Android.mk new file mode 100644 index 00000000..00252fcb --- /dev/null +++ b/src/external/android/native_app_glue/Android.mk @@ -0,0 +1,10 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE:= android_native_app_glue +LOCAL_SRC_FILES:= android_native_app_glue.c +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_EXPORT_LDLIBS := -llog + +include $(BUILD_STATIC_LIBRARY) diff --git a/src/external/android/native_app_glue/NOTICE b/src/external/android/native_app_glue/NOTICE new file mode 100644 index 00000000..d6c09229 --- /dev/null +++ b/src/external/android/native_app_glue/NOTICE @@ -0,0 +1,13 @@ +Copyright (C) 2016 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/src/external/android/native_app_glue/android_native_app_glue.c b/src/external/android/native_app_glue/android_native_app_glue.c new file mode 100644 index 00000000..d503d8da --- /dev/null +++ b/src/external/android/native_app_glue/android_native_app_glue.c @@ -0,0 +1,441 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include +#include + +#include "android_native_app_glue.h" +#include + +#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__)) +#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "threaded_app", __VA_ARGS__)) + +/* For debug builds, always enable the debug traces in this library */ +#ifndef NDEBUG +# define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "threaded_app", __VA_ARGS__)) +#else +# define LOGV(...) ((void)0) +#endif + +static void free_saved_state(struct android_app* android_app) { + pthread_mutex_lock(&android_app->mutex); + if (android_app->savedState != NULL) { + free(android_app->savedState); + android_app->savedState = NULL; + android_app->savedStateSize = 0; + } + pthread_mutex_unlock(&android_app->mutex); +} + +int8_t android_app_read_cmd(struct android_app* android_app) { + int8_t cmd; + if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) { + switch (cmd) { + case APP_CMD_SAVE_STATE: + free_saved_state(android_app); + break; + } + return cmd; + } else { + LOGE("No data on command pipe!"); + } + return -1; +} + +static void print_cur_config(struct android_app* android_app) { + char lang[2], country[2]; + AConfiguration_getLanguage(android_app->config, lang); + AConfiguration_getCountry(android_app->config, country); + + LOGV("Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d " + "keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d " + "modetype=%d modenight=%d", + AConfiguration_getMcc(android_app->config), + AConfiguration_getMnc(android_app->config), + lang[0], lang[1], country[0], country[1], + AConfiguration_getOrientation(android_app->config), + AConfiguration_getTouchscreen(android_app->config), + AConfiguration_getDensity(android_app->config), + AConfiguration_getKeyboard(android_app->config), + AConfiguration_getNavigation(android_app->config), + AConfiguration_getKeysHidden(android_app->config), + AConfiguration_getNavHidden(android_app->config), + AConfiguration_getSdkVersion(android_app->config), + AConfiguration_getScreenSize(android_app->config), + AConfiguration_getScreenLong(android_app->config), + AConfiguration_getUiModeType(android_app->config), + AConfiguration_getUiModeNight(android_app->config)); +} + +void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) { + switch (cmd) { + case APP_CMD_INPUT_CHANGED: + LOGV("APP_CMD_INPUT_CHANGED\n"); + pthread_mutex_lock(&android_app->mutex); + if (android_app->inputQueue != NULL) { + AInputQueue_detachLooper(android_app->inputQueue); + } + android_app->inputQueue = android_app->pendingInputQueue; + if (android_app->inputQueue != NULL) { + LOGV("Attaching input queue to looper"); + AInputQueue_attachLooper(android_app->inputQueue, + android_app->looper, LOOPER_ID_INPUT, NULL, + &android_app->inputPollSource); + } + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_INIT_WINDOW: + LOGV("APP_CMD_INIT_WINDOW\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->window = android_app->pendingWindow; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_TERM_WINDOW: + LOGV("APP_CMD_TERM_WINDOW\n"); + pthread_cond_broadcast(&android_app->cond); + break; + + case APP_CMD_RESUME: + case APP_CMD_START: + case APP_CMD_PAUSE: + case APP_CMD_STOP: + LOGV("activityState=%d\n", cmd); + pthread_mutex_lock(&android_app->mutex); + android_app->activityState = cmd; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_CONFIG_CHANGED: + LOGV("APP_CMD_CONFIG_CHANGED\n"); + AConfiguration_fromAssetManager(android_app->config, + android_app->activity->assetManager); + print_cur_config(android_app); + break; + + case APP_CMD_DESTROY: + LOGV("APP_CMD_DESTROY\n"); + android_app->destroyRequested = 1; + break; + } +} + +void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) { + switch (cmd) { + case APP_CMD_TERM_WINDOW: + LOGV("APP_CMD_TERM_WINDOW\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->window = NULL; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_SAVE_STATE: + LOGV("APP_CMD_SAVE_STATE\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->stateSaved = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_RESUME: + free_saved_state(android_app); + break; + } +} + +void app_dummy() { + +} + +static void android_app_destroy(struct android_app* android_app) { + LOGV("android_app_destroy!"); + free_saved_state(android_app); + pthread_mutex_lock(&android_app->mutex); + if (android_app->inputQueue != NULL) { + AInputQueue_detachLooper(android_app->inputQueue); + } + AConfiguration_delete(android_app->config); + android_app->destroyed = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + // Can't touch android_app object after this. +} + +static void process_input(struct android_app* app, struct android_poll_source* source) { + AInputEvent* event = NULL; + while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) { + LOGV("New input event: type=%d\n", AInputEvent_getType(event)); + if (AInputQueue_preDispatchEvent(app->inputQueue, event)) { + continue; + } + int32_t handled = 0; + if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); + AInputQueue_finishEvent(app->inputQueue, event, handled); + } +} + +static void process_cmd(struct android_app* app, struct android_poll_source* source) { + int8_t cmd = android_app_read_cmd(app); + android_app_pre_exec_cmd(app, cmd); + if (app->onAppCmd != NULL) app->onAppCmd(app, cmd); + android_app_post_exec_cmd(app, cmd); +} + +static void* android_app_entry(void* param) { + struct android_app* android_app = (struct android_app*)param; + + android_app->config = AConfiguration_new(); + AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager); + + print_cur_config(android_app); + + android_app->cmdPollSource.id = LOOPER_ID_MAIN; + android_app->cmdPollSource.app = android_app; + android_app->cmdPollSource.process = process_cmd; + android_app->inputPollSource.id = LOOPER_ID_INPUT; + android_app->inputPollSource.app = android_app; + android_app->inputPollSource.process = process_input; + + ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); + ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL, + &android_app->cmdPollSource); + android_app->looper = looper; + + pthread_mutex_lock(&android_app->mutex); + android_app->running = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + + android_main(android_app); + + android_app_destroy(android_app); + return NULL; +} + +// -------------------------------------------------------------------- +// Native activity interaction (called from main thread) +// -------------------------------------------------------------------- + +static struct android_app* android_app_create(ANativeActivity* activity, + void* savedState, size_t savedStateSize) { + struct android_app* android_app = (struct android_app*)malloc(sizeof(struct android_app)); + memset(android_app, 0, sizeof(struct android_app)); + android_app->activity = activity; + + pthread_mutex_init(&android_app->mutex, NULL); + pthread_cond_init(&android_app->cond, NULL); + + if (savedState != NULL) { + android_app->savedState = malloc(savedStateSize); + android_app->savedStateSize = savedStateSize; + memcpy(android_app->savedState, savedState, savedStateSize); + } + + int msgpipe[2]; + if (pipe(msgpipe)) { + LOGE("could not create pipe: %s", strerror(errno)); + return NULL; + } + android_app->msgread = msgpipe[0]; + android_app->msgwrite = msgpipe[1]; + + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_create(&android_app->thread, &attr, android_app_entry, android_app); + + // Wait for thread to start. + pthread_mutex_lock(&android_app->mutex); + while (!android_app->running) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); + + return android_app; +} + +static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { + if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { + LOGE("Failure writing android_app cmd: %s\n", strerror(errno)); + } +} + +static void android_app_set_input(struct android_app* android_app, AInputQueue* inputQueue) { + pthread_mutex_lock(&android_app->mutex); + android_app->pendingInputQueue = inputQueue; + android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED); + while (android_app->inputQueue != android_app->pendingInputQueue) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_set_window(struct android_app* android_app, ANativeWindow* window) { + pthread_mutex_lock(&android_app->mutex); + if (android_app->pendingWindow != NULL) { + android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW); + } + android_app->pendingWindow = window; + if (window != NULL) { + android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW); + } + while (android_app->window != android_app->pendingWindow) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_set_activity_state(struct android_app* android_app, int8_t cmd) { + pthread_mutex_lock(&android_app->mutex); + android_app_write_cmd(android_app, cmd); + while (android_app->activityState != cmd) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_free(struct android_app* android_app) { + pthread_mutex_lock(&android_app->mutex); + android_app_write_cmd(android_app, APP_CMD_DESTROY); + while (!android_app->destroyed) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); + + close(android_app->msgread); + close(android_app->msgwrite); + pthread_cond_destroy(&android_app->cond); + pthread_mutex_destroy(&android_app->mutex); + free(android_app); +} + +static void onDestroy(ANativeActivity* activity) { + LOGV("Destroy: %p\n", activity); + android_app_free((struct android_app*)activity->instance); +} + +static void onStart(ANativeActivity* activity) { + LOGV("Start: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_START); +} + +static void onResume(ANativeActivity* activity) { + LOGV("Resume: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_RESUME); +} + +static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) { + struct android_app* android_app = (struct android_app*)activity->instance; + void* savedState = NULL; + + LOGV("SaveInstanceState: %p\n", activity); + pthread_mutex_lock(&android_app->mutex); + android_app->stateSaved = 0; + android_app_write_cmd(android_app, APP_CMD_SAVE_STATE); + while (!android_app->stateSaved) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + + if (android_app->savedState != NULL) { + savedState = android_app->savedState; + *outLen = android_app->savedStateSize; + android_app->savedState = NULL; + android_app->savedStateSize = 0; + } + + pthread_mutex_unlock(&android_app->mutex); + + return savedState; +} + +static void onPause(ANativeActivity* activity) { + LOGV("Pause: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_PAUSE); +} + +static void onStop(ANativeActivity* activity) { + LOGV("Stop: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP); +} + +static void onConfigurationChanged(ANativeActivity* activity) { + struct android_app* android_app = (struct android_app*)activity->instance; + LOGV("ConfigurationChanged: %p\n", activity); + android_app_write_cmd(android_app, APP_CMD_CONFIG_CHANGED); +} + +static void onLowMemory(ANativeActivity* activity) { + struct android_app* android_app = (struct android_app*)activity->instance; + LOGV("LowMemory: %p\n", activity); + android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY); +} + +static void onWindowFocusChanged(ANativeActivity* activity, int focused) { + LOGV("WindowFocusChanged: %p -- %d\n", activity, focused); + android_app_write_cmd((struct android_app*)activity->instance, + focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS); +} + +static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window) { + LOGV("NativeWindowCreated: %p -- %p\n", activity, window); + android_app_set_window((struct android_app*)activity->instance, window); +} + +static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window) { + LOGV("NativeWindowDestroyed: %p -- %p\n", activity, window); + android_app_set_window((struct android_app*)activity->instance, NULL); +} + +static void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) { + LOGV("InputQueueCreated: %p -- %p\n", activity, queue); + android_app_set_input((struct android_app*)activity->instance, queue); +} + +static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) { + LOGV("InputQueueDestroyed: %p -- %p\n", activity, queue); + android_app_set_input((struct android_app*)activity->instance, NULL); +} + +void ANativeActivity_onCreate(ANativeActivity* activity, + void* savedState, size_t savedStateSize) { + LOGV("Creating: %p\n", activity); + activity->callbacks->onDestroy = onDestroy; + activity->callbacks->onStart = onStart; + activity->callbacks->onResume = onResume; + activity->callbacks->onSaveInstanceState = onSaveInstanceState; + activity->callbacks->onPause = onPause; + activity->callbacks->onStop = onStop; + activity->callbacks->onConfigurationChanged = onConfigurationChanged; + activity->callbacks->onLowMemory = onLowMemory; + activity->callbacks->onWindowFocusChanged = onWindowFocusChanged; + activity->callbacks->onNativeWindowCreated = onNativeWindowCreated; + activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed; + activity->callbacks->onInputQueueCreated = onInputQueueCreated; + activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed; + + activity->instance = android_app_create(activity, savedState, savedStateSize); +} diff --git a/src/external/android/native_app_glue/android_native_app_glue.h b/src/external/android/native_app_glue/android_native_app_glue.h new file mode 100644 index 00000000..97202e09 --- /dev/null +++ b/src/external/android/native_app_glue/android_native_app_glue.h @@ -0,0 +1,349 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _ANDROID_NATIVE_APP_GLUE_H +#define _ANDROID_NATIVE_APP_GLUE_H + +#include +#include +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The native activity interface provided by + * is based on a set of application-provided callbacks that will be called + * by the Activity's main thread when certain events occur. + * + * This means that each one of this callbacks _should_ _not_ block, or they + * risk having the system force-close the application. This programming + * model is direct, lightweight, but constraining. + * + * The 'android_native_app_glue' static library is used to provide a different + * execution model where the application can implement its own main event + * loop in a different thread instead. Here's how it works: + * + * 1/ The application must provide a function named "android_main()" that + * will be called when the activity is created, in a new thread that is + * distinct from the activity's main thread. + * + * 2/ android_main() receives a pointer to a valid "android_app" structure + * that contains references to other important objects, e.g. the + * ANativeActivity obejct instance the application is running in. + * + * 3/ the "android_app" object holds an ALooper instance that already + * listens to two important things: + * + * - activity lifecycle events (e.g. "pause", "resume"). See APP_CMD_XXX + * declarations below. + * + * - input events coming from the AInputQueue attached to the activity. + * + * Each of these correspond to an ALooper identifier returned by + * ALooper_pollOnce with values of LOOPER_ID_MAIN and LOOPER_ID_INPUT, + * respectively. + * + * Your application can use the same ALooper to listen to additional + * file-descriptors. They can either be callback based, or with return + * identifiers starting with LOOPER_ID_USER. + * + * 4/ Whenever you receive a LOOPER_ID_MAIN or LOOPER_ID_INPUT event, + * the returned data will point to an android_poll_source structure. You + * can call the process() function on it, and fill in android_app->onAppCmd + * and android_app->onInputEvent to be called for your own processing + * of the event. + * + * Alternatively, you can call the low-level functions to read and process + * the data directly... look at the process_cmd() and process_input() + * implementations in the glue to see how to do this. + * + * See the sample named "native-activity" that comes with the NDK with a + * full usage example. Also look at the JavaDoc of NativeActivity. + */ + +struct android_app; + +/** + * Data associated with an ALooper fd that will be returned as the "outData" + * when that source has data ready. + */ +struct android_poll_source { + // The identifier of this source. May be LOOPER_ID_MAIN or + // LOOPER_ID_INPUT. + int32_t id; + + // The android_app this ident is associated with. + struct android_app* app; + + // Function to call to perform the standard processing of data from + // this source. + void (*process)(struct android_app* app, struct android_poll_source* source); +}; + +/** + * This is the interface for the standard glue code of a threaded + * application. In this model, the application's code is running + * in its own thread separate from the main thread of the process. + * It is not required that this thread be associated with the Java + * VM, although it will need to be in order to make JNI calls any + * Java objects. + */ +struct android_app { + // The application can place a pointer to its own state object + // here if it likes. + void* userData; + + // Fill this in with the function to process main app commands (APP_CMD_*) + void (*onAppCmd)(struct android_app* app, int32_t cmd); + + // Fill this in with the function to process input events. At this point + // the event has already been pre-dispatched, and it will be finished upon + // return. Return 1 if you have handled the event, 0 for any default + // dispatching. + int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event); + + // The ANativeActivity object instance that this app is running in. + ANativeActivity* activity; + + // The current configuration the app is running in. + AConfiguration* config; + + // This is the last instance's saved state, as provided at creation time. + // It is NULL if there was no state. You can use this as you need; the + // memory will remain around until you call android_app_exec_cmd() for + // APP_CMD_RESUME, at which point it will be freed and savedState set to NULL. + // These variables should only be changed when processing a APP_CMD_SAVE_STATE, + // at which point they will be initialized to NULL and you can malloc your + // state and place the information here. In that case the memory will be + // freed for you later. + void* savedState; + size_t savedStateSize; + + // The ALooper associated with the app's thread. + ALooper* looper; + + // When non-NULL, this is the input queue from which the app will + // receive user input events. + AInputQueue* inputQueue; + + // When non-NULL, this is the window surface that the app can draw in. + ANativeWindow* window; + + // Current content rectangle of the window; this is the area where the + // window's content should be placed to be seen by the user. + ARect contentRect; + + // Current state of the app's activity. May be either APP_CMD_START, + // APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below. + int activityState; + + // This is non-zero when the application's NativeActivity is being + // destroyed and waiting for the app thread to complete. + int destroyRequested; + + // ------------------------------------------------- + // Below are "private" implementation of the glue code. + + pthread_mutex_t mutex; + pthread_cond_t cond; + + int msgread; + int msgwrite; + + pthread_t thread; + + struct android_poll_source cmdPollSource; + struct android_poll_source inputPollSource; + + int running; + int stateSaved; + int destroyed; + int redrawNeeded; + AInputQueue* pendingInputQueue; + ANativeWindow* pendingWindow; + ARect pendingContentRect; +}; + +enum { + /** + * Looper data ID of commands coming from the app's main thread, which + * is returned as an identifier from ALooper_pollOnce(). The data for this + * identifier is a pointer to an android_poll_source structure. + * These can be retrieved and processed with android_app_read_cmd() + * and android_app_exec_cmd(). + */ + LOOPER_ID_MAIN = 1, + + /** + * Looper data ID of events coming from the AInputQueue of the + * application's window, which is returned as an identifier from + * ALooper_pollOnce(). The data for this identifier is a pointer to an + * android_poll_source structure. These can be read via the inputQueue + * object of android_app. + */ + LOOPER_ID_INPUT = 2, + + /** + * Start of user-defined ALooper identifiers. + */ + LOOPER_ID_USER = 3, +}; + +enum { + /** + * Command from main thread: the AInputQueue has changed. Upon processing + * this command, android_app->inputQueue will be updated to the new queue + * (or NULL). + */ + APP_CMD_INPUT_CHANGED, + + /** + * Command from main thread: a new ANativeWindow is ready for use. Upon + * receiving this command, android_app->window will contain the new window + * surface. + */ + APP_CMD_INIT_WINDOW, + + /** + * Command from main thread: the existing ANativeWindow needs to be + * terminated. Upon receiving this command, android_app->window still + * contains the existing window; after calling android_app_exec_cmd + * it will be set to NULL. + */ + APP_CMD_TERM_WINDOW, + + /** + * Command from main thread: the current ANativeWindow has been resized. + * Please redraw with its new size. + */ + APP_CMD_WINDOW_RESIZED, + + /** + * Command from main thread: the system needs that the current ANativeWindow + * be redrawn. You should redraw the window before handing this to + * android_app_exec_cmd() in order to avoid transient drawing glitches. + */ + APP_CMD_WINDOW_REDRAW_NEEDED, + + /** + * Command from main thread: the content area of the window has changed, + * such as from the soft input window being shown or hidden. You can + * find the new content rect in android_app::contentRect. + */ + APP_CMD_CONTENT_RECT_CHANGED, + + /** + * Command from main thread: the app's activity window has gained + * input focus. + */ + APP_CMD_GAINED_FOCUS, + + /** + * Command from main thread: the app's activity window has lost + * input focus. + */ + APP_CMD_LOST_FOCUS, + + /** + * Command from main thread: the current device configuration has changed. + */ + APP_CMD_CONFIG_CHANGED, + + /** + * Command from main thread: the system is running low on memory. + * Try to reduce your memory use. + */ + APP_CMD_LOW_MEMORY, + + /** + * Command from main thread: the app's activity has been started. + */ + APP_CMD_START, + + /** + * Command from main thread: the app's activity has been resumed. + */ + APP_CMD_RESUME, + + /** + * Command from main thread: the app should generate a new saved state + * for itself, to restore from later if needed. If you have saved state, + * allocate it with malloc and place it in android_app.savedState with + * the size in android_app.savedStateSize. The will be freed for you + * later. + */ + APP_CMD_SAVE_STATE, + + /** + * Command from main thread: the app's activity has been paused. + */ + APP_CMD_PAUSE, + + /** + * Command from main thread: the app's activity has been stopped. + */ + APP_CMD_STOP, + + /** + * Command from main thread: the app's activity is being destroyed, + * and waiting for the app thread to clean up and exit before proceeding. + */ + APP_CMD_DESTROY, +}; + +/** + * Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next + * app command message. + */ +int8_t android_app_read_cmd(struct android_app* android_app); + +/** + * Call with the command returned by android_app_read_cmd() to do the + * initial pre-processing of the given command. You can perform your own + * actions for the command after calling this function. + */ +void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd); + +/** + * Call with the command returned by android_app_read_cmd() to do the + * final post-processing of the given command. You must have done your own + * actions for the command before calling this function. + */ +void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd); + +/** + * Dummy function you can call to ensure glue code isn't stripped. + */ +void app_dummy(); + +/** + * This is the function that application code must implement, representing + * the main entry to the app. + */ +extern void android_main(struct android_app* app); + +#ifdef __cplusplus +} +#endif + +#endif /* _ANDROID_NATIVE_APP_GLUE_H */ diff --git a/src/external/android_native_app_glue.h b/src/external/android_native_app_glue.h deleted file mode 100644 index 1b8c1f10..00000000 --- a/src/external/android_native_app_glue.h +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef _ANDROID_NATIVE_APP_GLUE_H -#define _ANDROID_NATIVE_APP_GLUE_H - -#include -#include -#include - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The native activity interface provided by - * is based on a set of application-provided callbacks that will be called - * by the Activity's main thread when certain events occur. - * - * This means that each one of this callbacks _should_ _not_ block, or they - * risk having the system force-close the application. This programming - * model is direct, lightweight, but constraining. - * - * The 'threaded_native_app' static library is used to provide a different - * execution model where the application can implement its own main event - * loop in a different thread instead. Here's how it works: - * - * 1/ The application must provide a function named "android_main()" that - * will be called when the activity is created, in a new thread that is - * distinct from the activity's main thread. - * - * 2/ android_main() receives a pointer to a valid "android_app" structure - * that contains references to other important objects, e.g. the - * ANativeActivity obejct instance the application is running in. - * - * 3/ the "android_app" object holds an ALooper instance that already - * listens to two important things: - * - * - activity lifecycle events (e.g. "pause", "resume"). See APP_CMD_XXX - * declarations below. - * - * - input events coming from the AInputQueue attached to the activity. - * - * Each of these correspond to an ALooper identifier returned by - * ALooper_pollOnce with values of LOOPER_ID_MAIN and LOOPER_ID_INPUT, - * respectively. - * - * Your application can use the same ALooper to listen to additional - * file-descriptors. They can either be callback based, or with return - * identifiers starting with LOOPER_ID_USER. - * - * 4/ Whenever you receive a LOOPER_ID_MAIN or LOOPER_ID_INPUT event, - * the returned data will point to an android_poll_source structure. You - * can call the process() function on it, and fill in android_app->onAppCmd - * and android_app->onInputEvent to be called for your own processing - * of the event. - * - * Alternatively, you can call the low-level functions to read and process - * the data directly... look at the process_cmd() and process_input() - * implementations in the glue to see how to do this. - * - * See the sample named "native-activity" that comes with the NDK with a - * full usage example. Also look at the JavaDoc of NativeActivity. - */ - -struct android_app; - -/** - * Data associated with an ALooper fd that will be returned as the "outData" - * when that source has data ready. - */ -struct android_poll_source { - // The identifier of this source. May be LOOPER_ID_MAIN or - // LOOPER_ID_INPUT. - int32_t id; - - // The android_app this ident is associated with. - struct android_app* app; - - // Function to call to perform the standard processing of data from - // this source. - void (*process)(struct android_app* app, struct android_poll_source* source); -}; - -/** - * This is the interface for the standard glue code of a threaded - * application. In this model, the application's code is running - * in its own thread separate from the main thread of the process. - * It is not required that this thread be associated with the Java - * VM, although it will need to be in order to make JNI calls any - * Java objects. - */ -struct android_app { - // The application can place a pointer to its own state object - // here if it likes. - void* userData; - - // Fill this in with the function to process main app commands (APP_CMD_*) - void (*onAppCmd)(struct android_app* app, int32_t cmd); - - // Fill this in with the function to process input events. At this point - // the event has already been pre-dispatched, and it will be finished upon - // return. Return 1 if you have handled the event, 0 for any default - // dispatching. - int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event); - - // The ANativeActivity object instance that this app is running in. - ANativeActivity* activity; - - // The current configuration the app is running in. - AConfiguration* config; - - // This is the last instance's saved state, as provided at creation time. - // It is NULL if there was no state. You can use this as you need; the - // memory will remain around until you call android_app_exec_cmd() for - // APP_CMD_RESUME, at which point it will be freed and savedState set to NULL. - // These variables should only be changed when processing a APP_CMD_SAVE_STATE, - // at which point they will be initialized to NULL and you can malloc your - // state and place the information here. In that case the memory will be - // freed for you later. - void* savedState; - size_t savedStateSize; - - // The ALooper associated with the app's thread. - ALooper* looper; - - // When non-NULL, this is the input queue from which the app will - // receive user input events. - AInputQueue* inputQueue; - - // When non-NULL, this is the window surface that the app can draw in. - ANativeWindow* window; - - // Current content rectangle of the window; this is the area where the - // window's content should be placed to be seen by the user. - ARect contentRect; - - // Current state of the app's activity. May be either APP_CMD_START, - // APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below. - int activityState; - - // This is non-zero when the application's NativeActivity is being - // destroyed and waiting for the app thread to complete. - int destroyRequested; - - // ------------------------------------------------- - // Below are "private" implementation of the glue code. - - pthread_mutex_t mutex; - pthread_cond_t cond; - - int msgread; - int msgwrite; - - pthread_t thread; - - struct android_poll_source cmdPollSource; - struct android_poll_source inputPollSource; - - int running; - int stateSaved; - int destroyed; - int redrawNeeded; - AInputQueue* pendingInputQueue; - ANativeWindow* pendingWindow; - ARect pendingContentRect; -}; - -enum { - /** - * Looper data ID of commands coming from the app's main thread, which - * is returned as an identifier from ALooper_pollOnce(). The data for this - * identifier is a pointer to an android_poll_source structure. - * These can be retrieved and processed with android_app_read_cmd() - * and android_app_exec_cmd(). - */ - LOOPER_ID_MAIN = 1, - - /** - * Looper data ID of events coming from the AInputQueue of the - * application's window, which is returned as an identifier from - * ALooper_pollOnce(). The data for this identifier is a pointer to an - * android_poll_source structure. These can be read via the inputQueue - * object of android_app. - */ - LOOPER_ID_INPUT = 2, - - /** - * Start of user-defined ALooper identifiers. - */ - LOOPER_ID_USER = 3, -}; - -enum { - /** - * Command from main thread: the AInputQueue has changed. Upon processing - * this command, android_app->inputQueue will be updated to the new queue - * (or NULL). - */ - APP_CMD_INPUT_CHANGED, - - /** - * Command from main thread: a new ANativeWindow is ready for use. Upon - * receiving this command, android_app->window will contain the new window - * surface. - */ - APP_CMD_INIT_WINDOW, - - /** - * Command from main thread: the existing ANativeWindow needs to be - * terminated. Upon receiving this command, android_app->window still - * contains the existing window; after calling android_app_exec_cmd - * it will be set to NULL. - */ - APP_CMD_TERM_WINDOW, - - /** - * Command from main thread: the current ANativeWindow has been resized. - * Please redraw with its new size. - */ - APP_CMD_WINDOW_RESIZED, - - /** - * Command from main thread: the system needs that the current ANativeWindow - * be redrawn. You should redraw the window before handing this to - * android_app_exec_cmd() in order to avoid transient drawing glitches. - */ - APP_CMD_WINDOW_REDRAW_NEEDED, - - /** - * Command from main thread: the content area of the window has changed, - * such as from the soft input window being shown or hidden. You can - * find the new content rect in android_app::contentRect. - */ - APP_CMD_CONTENT_RECT_CHANGED, - - /** - * Command from main thread: the app's activity window has gained - * input focus. - */ - APP_CMD_GAINED_FOCUS, - - /** - * Command from main thread: the app's activity window has lost - * input focus. - */ - APP_CMD_LOST_FOCUS, - - /** - * Command from main thread: the current device configuration has changed. - */ - APP_CMD_CONFIG_CHANGED, - - /** - * Command from main thread: the system is running low on memory. - * Try to reduce your memory use. - */ - APP_CMD_LOW_MEMORY, - - /** - * Command from main thread: the app's activity has been started. - */ - APP_CMD_START, - - /** - * Command from main thread: the app's activity has been resumed. - */ - APP_CMD_RESUME, - - /** - * Command from main thread: the app should generate a new saved state - * for itself, to restore from later if needed. If you have saved state, - * allocate it with malloc and place it in android_app.savedState with - * the size in android_app.savedStateSize. The will be freed for you - * later. - */ - APP_CMD_SAVE_STATE, - - /** - * Command from main thread: the app's activity has been paused. - */ - APP_CMD_PAUSE, - - /** - * Command from main thread: the app's activity has been stopped. - */ - APP_CMD_STOP, - - /** - * Command from main thread: the app's activity is being destroyed, - * and waiting for the app thread to clean up and exit before proceeding. - */ - APP_CMD_DESTROY, -}; - -/** - * Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next - * app command message. - */ -int8_t android_app_read_cmd(struct android_app* android_app); - -/** - * Call with the command returned by android_app_read_cmd() to do the - * initial pre-processing of the given command. You can perform your own - * actions for the command after calling this function. - */ -void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd); - -/** - * Call with the command returned by android_app_read_cmd() to do the - * final post-processing of the given command. You must have done your own - * actions for the command before calling this function. - */ -void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd); - -/** - * Dummy function you can call to ensure glue code isn't stripped. - */ -void app_dummy(); - -/** - * This is the function that application code must implement, representing - * the main entry to the app. - */ -extern void android_main(struct android_app* app); - -#ifdef __cplusplus -} -#endif - -#endif /* _ANDROID_NATIVE_APP_GLUE_H */ -- cgit v1.2.3 From 4a31ce4bd239cff7591e2f3795464d9076ecb7fd Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 18:07:23 +0200 Subject: Reorganize code --- games/arkanoid.c | 169 +++++++++++++++++++++++++------------------------------ 1 file changed, 77 insertions(+), 92 deletions(-) diff --git a/games/arkanoid.c b/games/arkanoid.c index f10f9383..6231fb8b 100644 --- a/games/arkanoid.c +++ b/games/arkanoid.c @@ -77,9 +77,6 @@ static void DrawGame(void); // Draw game (one frame) static void UnloadGame(void); // Unload game static void UpdateDrawFrame(void); // Update and Draw (one frame) -// Additional module functions -static void UpdateBall(void); - //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -165,13 +162,13 @@ void UpdateGame(void) if (!pause) { - // Player movement + // Player movement logic if (IsKeyDown(KEY_LEFT)) player.position.x -= 5; if ((player.position.x - player.size.x/2) <= 0) player.position.x = player.size.x/2; if (IsKeyDown(KEY_RIGHT)) player.position.x += 5; if ((player.position.x + player.size.x/2) >= screenWidth) player.position.x = screenWidth - player.size.x/2; - // Launch ball + // Ball launching logic if (!ball.active) { if (IsKeyPressed(KEY_SPACE)) @@ -181,7 +178,81 @@ void UpdateGame(void) } } - UpdateBall(); + // Ball movement logic + if (ball.active) + { + ball.position.x += ball.speed.x; + ball.position.y += ball.speed.y; + } + else + { + ball.position = (Vector2){ player.position.x, screenHeight*7/8 - 30 }; + } + + // Collision logic: ball vs walls + if (((ball.position.x + ball.radius) >= screenWidth) || ((ball.position.x - ball.radius) <= 0)) ball.speed.x *= -1; + if ((ball.position.y - ball.radius) <= 0) ball.speed.y *= -1; + if ((ball.position.y + ball.radius) >= screenHeight) + { + ball.speed = (Vector2){ 0, 0 }; + ball.active = false; + + player.life--; + } + + // Collision logic: ball vs player + if (CheckCollisionCircleRec(ball.position, ball.radius, + (Rectangle){ player.position.x - player.size.x/2, player.position.y - player.size.y/2, player.size.x, player.size.y})) + { + if (ball.speed.y > 0) + { + ball.speed.y *= -1; + ball.speed.x = (ball.position.x - player.position.x)/(player.size.x/2)*5; + } + } + + // Collision logic: ball vs bricks + for (int i = 0; i < LINES_OF_BRICKS; i++) + { + for (int j = 0; j < BRICKS_PER_LINE; j++) + { + if (brick[i][j].active) + { + // Hit below + if (((ball.position.y - ball.radius) <= (brick[i][j].position.y + brickSize.y/2)) && + ((ball.position.y - ball.radius) > (brick[i][j].position.y + brickSize.y/2 + ball.speed.y)) && + ((fabs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) && (ball.speed.y < 0)) + { + brick[i][j].active = false; + ball.speed.y *= -1; + } + // Hit above + else if (((ball.position.y + ball.radius) >= (brick[i][j].position.y - brickSize.y/2)) && + ((ball.position.y + ball.radius) < (brick[i][j].position.y - brickSize.y/2 + ball.speed.y)) && + ((fabs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) && (ball.speed.y > 0)) + { + brick[i][j].active = false; + ball.speed.y *= -1; + } + // Hit left + else if (((ball.position.x + ball.radius) >= (brick[i][j].position.x - brickSize.x/2)) && + ((ball.position.x + ball.radius) < (brick[i][j].position.x - brickSize.x/2 + ball.speed.x)) && + ((fabs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) && (ball.speed.x > 0)) + { + brick[i][j].active = false; + ball.speed.x *= -1; + } + // Hit right + else if (((ball.position.x - ball.radius) <= (brick[i][j].position.x + brickSize.x/2)) && + ((ball.position.x - ball.radius) > (brick[i][j].position.x + brickSize.x/2 + ball.speed.x)) && + ((fabs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) && (ball.speed.x < 0)) + { + brick[i][j].active = false; + ball.speed.x *= -1; + } + } + } + } // Game over logic if (player.life <= 0) gameOver = true; @@ -260,90 +331,4 @@ void UpdateDrawFrame(void) { UpdateGame(); DrawGame(); -} - -//-------------------------------------------------------------------------------------- -// Additional module functions -//-------------------------------------------------------------------------------------- -static void UpdateBall() -{ - // Update position - if (ball.active) - { - ball.position.x += ball.speed.x; - ball.position.y += ball.speed.y; - } - else - { - ball.position = (Vector2){ player.position.x, screenHeight*7/8 - 30 }; - } - - // Bounce in x - if (((ball.position.x + ball.radius) >= screenWidth) || ((ball.position.x - ball.radius) <= 0)) ball.speed.x *= -1; - - // Bounce in y - if ((ball.position.y - ball.radius) <= 0) ball.speed.y *= -1; - - // Ball reaches bottom of the screen - if ((ball.position.y + ball.radius) >= screenHeight) - { - ball.speed = (Vector2){ 0, 0 }; - ball.active = false; - - player.life--; - } - - // Collision logic: ball vs player - if (CheckCollisionCircleRec(ball.position, ball.radius, - (Rectangle){ player.position.x - player.size.x/2, player.position.y - player.size.y/2, player.size.x, player.size.y})) - { - if (ball.speed.y > 0) - { - ball.speed.y *= -1; - ball.speed.x = (ball.position.x - player.position.x)/(player.size.x/2)*5; - } - } - - // Collision logic: ball vs bricks - for (int i = 0; i < LINES_OF_BRICKS; i++) - { - for (int j = 0; j < BRICKS_PER_LINE; j++) - { - if (brick[i][j].active) - { - // Hit below - if (((ball.position.y - ball.radius) <= (brick[i][j].position.y + brickSize.y/2)) && - ((ball.position.y - ball.radius) > (brick[i][j].position.y + brickSize.y/2 + ball.speed.y)) && - ((fabs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) && (ball.speed.y < 0)) - { - brick[i][j].active = false; - ball.speed.y *= -1; - } - // Hit above - else if (((ball.position.y + ball.radius) >= (brick[i][j].position.y - brickSize.y/2)) && - ((ball.position.y + ball.radius) < (brick[i][j].position.y - brickSize.y/2 + ball.speed.y)) && - ((fabs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) && (ball.speed.y > 0)) - { - brick[i][j].active = false; - ball.speed.y *= -1; - } - // Hit left - else if (((ball.position.x + ball.radius) >= (brick[i][j].position.x - brickSize.x/2)) && - ((ball.position.x + ball.radius) < (brick[i][j].position.x - brickSize.x/2 + ball.speed.x)) && - ((fabs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) && (ball.speed.x > 0)) - { - brick[i][j].active = false; - ball.speed.x *= -1; - } - // Hit right - else if (((ball.position.x - ball.radius) <= (brick[i][j].position.x + brickSize.x/2)) && - ((ball.position.x - ball.radius) > (brick[i][j].position.x + brickSize.x/2 + ball.speed.x)) && - ((fabs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) && (ball.speed.x < 0)) - { - brick[i][j].active = false; - ball.speed.x *= -1; - } - } - } - } } \ No newline at end of file -- cgit v1.2.3 From 6a48e7376bb83566617f3f4406f7a90c5b889809 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 18:20:27 +0200 Subject: Review example --- games/asteroids.c | 95 +++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 49 deletions(-) diff --git a/games/asteroids.c b/games/asteroids.c index 53ebbd8e..11063889 100644 --- a/games/asteroids.c +++ b/games/asteroids.c @@ -82,9 +82,9 @@ static Meteor bigMeteor[MAX_BIG_METEORS]; static Meteor mediumMeteor[MAX_MEDIUM_METEORS]; static Meteor smallMeteor[MAX_SMALL_METEORS]; -static int countMediumMeteors; -static int countSmallMeteors; -static int meteorsDestroyed; +static int midMeteorsCount; +static int smallMeteorsCount; +static int destroyedMeteorsCount; //------------------------------------------------------------------------------------ // Module Functions Declaration (local) @@ -95,7 +95,6 @@ static void DrawGame(void); // Draw game (one frame) static void UnloadGame(void); // Unload game static void UpdateDrawFrame(void); // Update and Draw (one frame) -static void InitShoot(Shoot shoot); static void DrawSpaceship(Vector2 position, float rotation, Color color); //------------------------------------------------------------------------------------ @@ -164,7 +163,7 @@ void InitGame(void) player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12}; player.color = LIGHTGRAY; - meteorsDestroyed = 0; + destroyedMeteorsCount = 0; // Initialization shoot for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) @@ -237,8 +236,8 @@ void InitGame(void) smallMeteor[i].color = BLUE; } - countMediumMeteors = 0; - countSmallMeteors = 0; + midMeteorsCount = 0; + smallMeteorsCount = 0; } // Update game (one frame) @@ -250,17 +249,15 @@ void UpdateGame(void) if (!pause) { - // Player logic - - // Rotation + // Player logic: rotation if (IsKeyDown(KEY_LEFT)) player.rotation -= 5; if (IsKeyDown(KEY_RIGHT)) player.rotation += 5; - // Speed + // Player logic: speed player.speed.x = sin(player.rotation*DEG2RAD)*PLAYER_SPEED; player.speed.y = cos(player.rotation*DEG2RAD)*PLAYER_SPEED; - // Controller + // Player logic: acceleration if (IsKeyDown(KEY_UP)) { if (player.acceleration < 1) player.acceleration += 0.04f; @@ -276,17 +273,17 @@ void UpdateGame(void) else if (player.acceleration < 0) player.acceleration = 0; } - // Movement + // Player logic: movement player.position.x += (player.speed.x*player.acceleration); player.position.y -= (player.speed.y*player.acceleration); - // Wall behaviour for player + // Collision logic: player vs walls if (player.position.x > screenWidth + shipHeight) player.position.x = -(shipHeight); else if (player.position.x < -(shipHeight)) player.position.x = screenWidth + shipHeight; if (player.position.y > (screenHeight + shipHeight)) player.position.y = -(shipHeight); else if (player.position.y < -(shipHeight)) player.position.y = screenHeight + shipHeight; - // Activation of shoot + // Player shoot logic if (IsKeyPressed(KEY_SPACE)) { for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) @@ -318,7 +315,7 @@ void UpdateGame(void) shoot[i].position.x += shoot[i].speed.x; shoot[i].position.y -= shoot[i].speed.y; - // Wall behaviour for shoot + // Collision logic: shoot vs walls if (shoot[i].position.x > screenWidth + shoot[i].radius) { shoot[i].active = false; @@ -351,7 +348,7 @@ void UpdateGame(void) } } - // Collision Player to meteors + // Collision logic: player vs meteors player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12}; for (int a = 0; a < MAX_BIG_METEORS; a++) @@ -369,16 +366,16 @@ void UpdateGame(void) if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, smallMeteor[a].position, smallMeteor[a].radius) && smallMeteor[a].active) gameOver = true; } - // Meteor logic + // Meteors logic: big meteors for (int i = 0; i < MAX_BIG_METEORS; i++) { if (bigMeteor[i].active) { - // movement + // Movement bigMeteor[i].position.x += bigMeteor[i].speed.x; bigMeteor[i].position.y += bigMeteor[i].speed.y; - // wall behaviour + // Collision logic: meteor vs wall if (bigMeteor[i].position.x > screenWidth + bigMeteor[i].radius) bigMeteor[i].position.x = -(bigMeteor[i].radius); else if (bigMeteor[i].position.x < 0 - bigMeteor[i].radius) bigMeteor[i].position.x = screenWidth + bigMeteor[i].radius; if (bigMeteor[i].position.y > screenHeight + bigMeteor[i].radius) bigMeteor[i].position.y = -(bigMeteor[i].radius); @@ -386,15 +383,16 @@ void UpdateGame(void) } } + // Meteors logic: medium meteors for (int i = 0; i < MAX_MEDIUM_METEORS; i++) { if (mediumMeteor[i].active) { - // movement + // Movement mediumMeteor[i].position.x += mediumMeteor[i].speed.x; mediumMeteor[i].position.y += mediumMeteor[i].speed.y; - // wall behaviour + // Collision logic: meteor vs wall if (mediumMeteor[i].position.x > screenWidth + mediumMeteor[i].radius) mediumMeteor[i].position.x = -(mediumMeteor[i].radius); else if (mediumMeteor[i].position.x < 0 - mediumMeteor[i].radius) mediumMeteor[i].position.x = screenWidth + mediumMeteor[i].radius; if (mediumMeteor[i].position.y > screenHeight + mediumMeteor[i].radius) mediumMeteor[i].position.y = -(mediumMeteor[i].radius); @@ -402,15 +400,16 @@ void UpdateGame(void) } } + // Meteors logic: small meteors for (int i = 0; i < MAX_SMALL_METEORS; i++) { if (smallMeteor[i].active) { - // movement + // Movement smallMeteor[i].position.x += smallMeteor[i].speed.x; smallMeteor[i].position.y += smallMeteor[i].speed.y; - // wall behaviour + // Collision logic: meteor vs wall if (smallMeteor[i].position.x > screenWidth + smallMeteor[i].radius) smallMeteor[i].position.x = -(smallMeteor[i].radius); else if (smallMeteor[i].position.x < 0 - smallMeteor[i].radius) smallMeteor[i].position.x = screenWidth + smallMeteor[i].radius; if (smallMeteor[i].position.y > screenHeight + smallMeteor[i].radius) smallMeteor[i].position.y = -(smallMeteor[i].radius); @@ -418,7 +417,7 @@ void UpdateGame(void) } } - // Collision behaviour + // Collision logic: player-shoots vs meteors for (int i = 0; i < PLAYER_MAX_SHOOTS; i++) { if ((shoot[i].active)) @@ -430,31 +429,30 @@ void UpdateGame(void) shoot[i].active = false; shoot[i].lifeSpawn = 0; bigMeteor[a].active = false; - meteorsDestroyed++; + destroyedMeteorsCount++; + for (int j = 0; j < 2; j ++) { - if (countMediumMeteors%2 == 0) + if (midMeteorsCount%2 == 0) { - mediumMeteor[countMediumMeteors].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y}; - mediumMeteor[countMediumMeteors].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1}; + mediumMeteor[midMeteorsCount].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y}; + mediumMeteor[midMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1}; } else { - mediumMeteor[countMediumMeteors].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y}; - mediumMeteor[countMediumMeteors].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED}; + mediumMeteor[midMeteorsCount].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y}; + mediumMeteor[midMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED}; } - mediumMeteor[countMediumMeteors].active = true; - countMediumMeteors ++; + mediumMeteor[midMeteorsCount].active = true; + midMeteorsCount ++; } //bigMeteor[a].position = (Vector2){-100, -100}; bigMeteor[a].color = RED; a = MAX_BIG_METEORS; } } - } - if ((shoot[i].active)) - { + for (int b = 0; b < MAX_MEDIUM_METEORS; b++) { if (mediumMeteor[b].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, mediumMeteor[b].position, mediumMeteor[b].radius)) @@ -462,31 +460,30 @@ void UpdateGame(void) shoot[i].active = false; shoot[i].lifeSpawn = 0; mediumMeteor[b].active = false; - meteorsDestroyed++; + destroyedMeteorsCount++; + for (int j = 0; j < 2; j ++) { - if (countSmallMeteors%2 == 0) + if (smallMeteorsCount%2 == 0) { - smallMeteor[countSmallMeteors].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y}; - smallMeteor[countSmallMeteors].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1}; + smallMeteor[smallMeteorsCount].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y}; + smallMeteor[smallMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1}; } else { - smallMeteor[countSmallMeteors].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y}; - smallMeteor[countSmallMeteors].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED}; + smallMeteor[smallMeteorsCount].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y}; + smallMeteor[smallMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED}; } - smallMeteor[countSmallMeteors].active = true; - countSmallMeteors ++; + smallMeteor[smallMeteorsCount].active = true; + smallMeteorsCount ++; } //mediumMeteor[b].position = (Vector2){-100, -100}; mediumMeteor[b].color = GREEN; b = MAX_MEDIUM_METEORS; } } - } - if ((shoot[i].active)) - { + for (int c = 0; c < MAX_SMALL_METEORS; c++) { if (smallMeteor[c].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, smallMeteor[c].position, smallMeteor[c].radius)) @@ -494,7 +491,7 @@ void UpdateGame(void) shoot[i].active = false; shoot[i].lifeSpawn = 0; smallMeteor[c].active = false; - meteorsDestroyed++; + destroyedMeteorsCount++; smallMeteor[c].color = YELLOW; // smallMeteor[c].position = (Vector2){-100, -100}; c = MAX_SMALL_METEORS; @@ -504,7 +501,7 @@ void UpdateGame(void) } } - if (meteorsDestroyed == MAX_BIG_METEORS + MAX_MEDIUM_METEORS + MAX_SMALL_METEORS) victory = true; + if (destroyedMeteorsCount == MAX_BIG_METEORS + MAX_MEDIUM_METEORS + MAX_SMALL_METEORS) victory = true; } else { -- cgit v1.2.3 From a8f142e736aebaca59dcc71c6b20486b6ecbbf31 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 18:23:09 +0200 Subject: Renamed file --- games/Makefile | 319 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ games/makefile | 319 --------------------------------------------------------- 2 files changed, 319 insertions(+), 319 deletions(-) create mode 100644 games/Makefile delete mode 100644 games/makefile diff --git a/games/Makefile b/games/Makefile new file mode 100644 index 00000000..60f38bff --- /dev/null +++ b/games/Makefile @@ -0,0 +1,319 @@ +#************************************************************************************************** +# +# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) +# +# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) +# +# This software is provided "as-is", without any express or implied warranty. In no event +# will the authors be held liable for any damages arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, including commercial +# applications, and to alter it and redistribute it freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim that you +# wrote the original software. If you use this software in a product, an acknowledgment +# in the product documentation would be appreciated but is not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be misrepresented +# as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution. +# +#************************************************************************************************** + +.PHONY: all clean + +# define raylib platform to compile for +# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB +# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() +PLATFORM ?= PLATFORM_DESKTOP + +# define NO to use OpenAL Soft as static library (shared by default) +SHARED_OPENAL ?= NO + +ifeq ($(PLATFORM),PLATFORM_WEB) + SHARED_OPENAL = NO +endif + +# define raylib directory for include and library +RAYLIB_PATH ?= C:\raylib\raylib + +# determine PLATFORM_OS in case PLATFORM_DESKTOP selected +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows + ifeq ($(OS),Windows_NT) + PLATFORM_OS=WINDOWS + LIBPATH=win32 + else + UNAMEOS:=$(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS=LINUX + LIBPATH=linux + else + ifeq ($(UNAMEOS),Darwin) + PLATFORM_OS=OSX + LIBPATH=osx + endif + endif + endif +endif + +# define compiler: gcc for C program, define as g++ for C++ +ifeq ($(PLATFORM),PLATFORM_WEB) + # define emscripten compiler + CC = emcc +else +ifeq ($(PLATFORM_OS),OSX) + # define llvm compiler for mac + CC = clang +else + # define default gcc compiler + CC = gcc +endif +endif + +# define compiler flags: +# -O2 defines optimization level +# -Og enable debugging +# -s strip unnecessary data from build +# -Wall turns on most, but not all, compiler warnings +# -std=c99 defines C language mode (standard C from 1999 revision) +# -std=gnu99 defines C language mode (GNU C from 1999 revision) +# -fgnu89-inline declaring inline functions support (GCC optimized) +# -Wno-missing-braces ignore invalid warning (GCC bug 53119) +# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + CFLAGS = -O2 -s -Wall -std=c99 + endif + ifeq ($(PLATFORM_OS),LINUX) + CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE + endif + ifeq ($(PLATFORM_OS),OSX) + CFLAGS = -O2 -s -Wall -std=c99 + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s --profiling + # -O2 # if used, also set --memory-init-file 0 + # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) + # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing + # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # --preload-file file.res # embbed file.res resource into .data file +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline +endif +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define raylib release directory for compiled library +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 + endif + ifeq ($(PLATFORM_OS),LINUX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux + endif + ifeq ($(PLATFORM_OS),OSX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi +endif + +# define any directories containing required header files +INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external + +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries headers + # GLFW3 + INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include + # OpenAL Soft + INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include + endif + ifeq ($(PLATFORM_OS),LINUX) + # you may optionally create this directory and install raylib + # and related headers there. Edit ../src/Makefile appropriately. + INCLUDES += -I/usr/local/include/raylib + endif + ifeq ($(PLATFORM_OS),OSX) + # additional directories for MacOS + endif +endif + +# define library paths containing required libs +LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src + +ifeq ($(PLATFORM),PLATFORM_RPI) + LFLAGS += -L/opt/vc/lib +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # add standard directories for GNU/Linux + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries to link with + # GLFW3 + LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) + # OpenAL Soft + LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) + endif +endif + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),LINUX) + # libraries for Debian GNU/Linux desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl + # on XWindow requires also below libraries + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + else + ifeq ($(PLATFORM_OS),OSX) + # libraries for OSX 10.9 desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa + else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 + # if static OpenAL Soft required, define the corresponding libs + ifeq ($(SHARED_OPENAL),NO) + LIBS += -lopenal32 -lwinmm + CFLAGS += -Wl,-allow-multiple-definition + else + LIBS += -lopenal32dll + endif + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + # NOTE: Set the correct path to libraylib.bc + LIBS = $(RAYLIB_RELEASE)/libraylib.bc +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM_OS),WINDOWS) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows +endif + +ifeq ($(PLATFORM),PLATFORM_WEB) + EXT = .html + WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html +endif + +# define all object files required +SAMPLES = \ + arkanoid \ + asteroids \ + asteroids_survival \ + floppy \ + gold_fever \ + gorilas \ + missile_commander \ + pang \ + snake \ + space_invaders \ + tetris \ + fix_dylib \ + + +# typing 'make' will invoke the default target entry +default: samples + +# compile all game samples +samples: $(SAMPLES) + +# compile game sample - arkanoid +arkanoid: arkanoid.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - steroids +asteroids: asteroids.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - asteroids_survival +asteroids_survival: asteroids_survival.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - floppy +floppy: floppy.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - gold_fever +gold_fever: gold_fever.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - gorilas +gorilas: gorilas.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - missile_commander +missile_commander: missile_commander.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - pang +pang: pang.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - snake +snake: snake.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - space_invaders +space_invaders: space_invaders.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile game sample - tetris +tetris: tetris.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# fix dylib install path name for each executable (MAC) +fix_dylib: +ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -print0 | xargs -t -0 -R 1 -I file install_name_tool -change libglfw.3.0.dylib ../external/glfw3/lib/osx/libglfw.3.0.dylib file +endif + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -delete + rm -f *.o + else + ifeq ($(PLATFORM_OS),LINUX) + find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f + else + del *.o *.exe /s + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + find . -type f -executable -delete + rm -f *.o +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + del *.o *.html *.js +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/makefile b/games/makefile deleted file mode 100644 index 60f38bff..00000000 --- a/games/makefile +++ /dev/null @@ -1,319 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) -# -# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# define raylib platform to compile for -# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB -# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() -PLATFORM ?= PLATFORM_DESKTOP - -# define NO to use OpenAL Soft as static library (shared by default) -SHARED_OPENAL ?= NO - -ifeq ($(PLATFORM),PLATFORM_WEB) - SHARED_OPENAL = NO -endif - -# define raylib directory for include and library -RAYLIB_PATH ?= C:\raylib\raylib - -# determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - LIBPATH=win32 - else - UNAMEOS:=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - LIBPATH=linux - else - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - LIBPATH=osx - endif - endif - endif -endif - -# define compiler: gcc for C program, define as g++ for C++ -ifeq ($(PLATFORM),PLATFORM_WEB) - # define emscripten compiler - CC = emcc -else -ifeq ($(PLATFORM_OS),OSX) - # define llvm compiler for mac - CC = clang -else - # define default gcc compiler - CC = gcc -endif -endif - -# define compiler flags: -# -O2 defines optimization level -# -Og enable debugging -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -fgnu89-inline declaring inline functions support (GCC optimized) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - CFLAGS = -O2 -s -Wall -std=c99 - endif - ifeq ($(PLATFORM_OS),LINUX) - CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE - endif - ifeq ($(PLATFORM_OS),OSX) - CFLAGS = -O2 -s -Wall -std=c99 - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s --profiling - # -O2 # if used, also set --memory-init-file 0 - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # --preload-file file.res # embbed file.res resource into .data file -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline -endif -#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes - -# define raylib release directory for compiled library -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 - endif - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux - endif - ifeq ($(PLATFORM_OS),OSX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi -endif - -# define any directories containing required header files -INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -ifeq ($(PLATFORM),PLATFORM_RPI) - INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries headers - # GLFW3 - INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include - # OpenAL Soft - INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # you may optionally create this directory and install raylib - # and related headers there. Edit ../src/Makefile appropriately. - INCLUDES += -I/usr/local/include/raylib - endif - ifeq ($(PLATFORM_OS),OSX) - # additional directories for MacOS - endif -endif - -# define library paths containing required libs -LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_RPI) - LFLAGS += -L/opt/vc/lib -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # add standard directories for GNU/Linux - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries to link with - # GLFW3 - LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) - # OpenAL Soft - LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) - endif -endif - -# define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - # libraries for Debian GNU/Linux desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl - # on XWindow requires also below libraries - LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - else - ifeq ($(PLATFORM_OS),OSX) - # libraries for OSX 10.9 desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa - else - # libraries for Windows desktop compiling - # NOTE: GLFW3 and OpenAL Soft libraries should be installed - LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 - # if static OpenAL Soft required, define the corresponding libs - ifeq ($(SHARED_OPENAL),NO) - LIBS += -lopenal32 -lwinmm - CFLAGS += -Wl,-allow-multiple-definition - else - LIBS += -lopenal32dll - endif - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # libraries for Raspberry Pi compiling - # NOTE: OpenAL Soft library should be installed (libopenal1 package) - LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # NOTE: Set the correct path to libraylib.bc - LIBS = $(RAYLIB_RELEASE)/libraylib.bc -endif - -# define additional parameters and flags for windows -ifeq ($(PLATFORM_OS),WINDOWS) - # resources file contains windows exe icon - # -Wl,--subsystem,windows hides the console window - WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - EXT = .html - WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html -endif - -# define all object files required -SAMPLES = \ - arkanoid \ - asteroids \ - asteroids_survival \ - floppy \ - gold_fever \ - gorilas \ - missile_commander \ - pang \ - snake \ - space_invaders \ - tetris \ - fix_dylib \ - - -# typing 'make' will invoke the default target entry -default: samples - -# compile all game samples -samples: $(SAMPLES) - -# compile game sample - arkanoid -arkanoid: arkanoid.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - steroids -asteroids: asteroids.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - asteroids_survival -asteroids_survival: asteroids_survival.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - floppy -floppy: floppy.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - gold_fever -gold_fever: gold_fever.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - gorilas -gorilas: gorilas.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - missile_commander -missile_commander: missile_commander.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - pang -pang: pang.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - snake -snake: snake.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - space_invaders -space_invaders: space_invaders.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile game sample - tetris -tetris: tetris.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# fix dylib install path name for each executable (MAC) -fix_dylib: -ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -print0 | xargs -t -0 -R 1 -I file install_name_tool -change libglfw.3.0.dylib ../external/glfw3/lib/osx/libglfw.3.0.dylib file -endif - -# clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - else - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f - else - del *.o *.exe /s - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -f *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - -# instead of defining every module one by one, we can define a pattern -# this pattern below will automatically compile every module defined on $(OBJS) -#%.exe : %.c -# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) -- cgit v1.2.3 From 4ca229ed7f0d0b65fbc908933576e18bf2aed2e7 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 18:26:53 +0200 Subject: Renamed file --- games/drturtle/Makefile | 257 ++++++++++++++++++++++++++++++++ games/drturtle/makefile | 257 -------------------------------- games/just_do/Makefile | 312 +++++++++++++++++++++++++++++++++++++++ games/just_do/makefile | 312 --------------------------------------- games/light_my_ritual/Makefile | 272 ++++++++++++++++++++++++++++++++++ games/light_my_ritual/makefile | 272 ---------------------------------- games/skully_escape/Makefile | 322 +++++++++++++++++++++++++++++++++++++++++ games/skully_escape/makefile | 322 ----------------------------------------- 8 files changed, 1163 insertions(+), 1163 deletions(-) create mode 100644 games/drturtle/Makefile delete mode 100644 games/drturtle/makefile create mode 100644 games/just_do/Makefile delete mode 100644 games/just_do/makefile create mode 100644 games/light_my_ritual/Makefile delete mode 100644 games/light_my_ritual/makefile create mode 100644 games/skully_escape/Makefile delete mode 100644 games/skully_escape/makefile diff --git a/games/drturtle/Makefile b/games/drturtle/Makefile new file mode 100644 index 00000000..89821929 --- /dev/null +++ b/games/drturtle/Makefile @@ -0,0 +1,257 @@ +#************************************************************************************************** +# +# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) +# +# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) +# +# This software is provided "as-is", without any express or implied warranty. In no event +# will the authors be held liable for any damages arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, including commercial +# applications, and to alter it and redistribute it freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim that you +# wrote the original software. If you use this software in a product, an acknowledgment +# in the product documentation would be appreciated but is not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be misrepresented +# as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution. +# +#************************************************************************************************** + +.PHONY: all clean + +# define raylib platform to compile for +# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB +# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() +PLATFORM ?= PLATFORM_DESKTOP + +# define NO to use OpenAL Soft as static library (shared by default) +SHARED_OPENAL ?= NO + +ifeq ($(PLATFORM),PLATFORM_WEB) + SHARED_OPENAL = NO +endif + +# define raylib directory for include and library +RAYLIB_PATH ?= C:\raylib\raylib + +# determine PLATFORM_OS in case PLATFORM_DESKTOP selected +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows + ifeq ($(OS),Windows_NT) + PLATFORM_OS=WINDOWS + LIBPATH=win32 + else + UNAMEOS:=$(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS=LINUX + LIBPATH=linux + else + ifeq ($(UNAMEOS),Darwin) + PLATFORM_OS=OSX + LIBPATH=osx + endif + endif + endif +endif + +# define compiler: gcc for C program, define as g++ for C++ +ifeq ($(PLATFORM),PLATFORM_WEB) + # define emscripten compiler + CC = emcc +else +ifeq ($(PLATFORM_OS),OSX) + # define llvm compiler for mac + CC = clang +else + # define default gcc compiler + CC = gcc +endif +endif + +# define compiler flags: +# -O2 defines optimization level +# -Og enable debugging +# -s strip unnecessary data from build +# -Wall turns on most, but not all, compiler warnings +# -std=c99 defines C language mode (standard C from 1999 revision) +# -std=gnu99 defines C language mode (GNU C from 1999 revision) +# -fgnu89-inline declaring inline functions support (GCC optimized) +# -Wno-missing-braces ignore invalid warning (GCC bug 53119) +# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + CFLAGS = -O2 -s -Wall -std=c99 + endif + ifeq ($(PLATFORM_OS),LINUX) + CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE + endif + ifeq ($(PLATFORM_OS),OSX) + CFLAGS = -O2 -s -Wall -std=c99 + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=33554432 --profiling --preload-file resources + # -O2 # if used, also set --memory-init-file 0 + # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) + # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing + # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # --preload-file file.res # embbed file.res resource into .data file +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline +endif +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define raylib release directory for compiled library +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 + endif + ifeq ($(PLATFORM_OS),LINUX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux + endif + ifeq ($(PLATFORM_OS),OSX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi +endif + +# define any directories containing required header files +INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external + +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries headers + # GLFW3 + INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include + # OpenAL Soft + INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include + endif + ifeq ($(PLATFORM_OS),LINUX) + # you may optionally create this directory and install raylib + # and related headers there. Edit ../src/Makefile appropriately. + INCLUDES += -I/usr/local/include/raylib + endif + ifeq ($(PLATFORM_OS),OSX) + # additional directories for MacOS + endif +endif + +# define library paths containing required libs +LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src + +ifeq ($(PLATFORM),PLATFORM_RPI) + LFLAGS += -L/opt/vc/lib +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # add standard directories for GNU/Linux + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries to link with + # GLFW3 + LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) + # OpenAL Soft + LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) + endif +endif + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),LINUX) + # libraries for Debian GNU/Linux desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl + # on XWindow requires also below libraries + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + else + ifeq ($(PLATFORM_OS),OSX) + # libraries for OSX 10.9 desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa + else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 + # if static OpenAL Soft required, define the corresponding libs + ifeq ($(SHARED_OPENAL),NO) + LIBS += -lopenal32 -lwinmm + CFLAGS += -Wl,-allow-multiple-definition + else + LIBS += -lopenal32dll + endif + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + # NOTE: Set the correct path to libraylib.bc + LIBS = $(RAYLIB_RELEASE)/libraylib.bc +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM_OS),WINDOWS) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows +endif + +ifeq ($(PLATFORM),PLATFORM_WEB) + EXT = .html + WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html +endif + +# define all screen object files required +SCREENS = \ + +# typing 'make' will invoke the default target entry +default: drturtle + +# compile program +drturtle: drturtle_final_web.c $(SCREENS) + $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -delete + rm -f *.o + else + ifeq ($(PLATFORM_OS),LINUX) + find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f + else + del *.o *.exe /s + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + find . -type f -executable -delete + rm -f *.o +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + del *.o *.html *.js +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/drturtle/makefile b/games/drturtle/makefile deleted file mode 100644 index 89821929..00000000 --- a/games/drturtle/makefile +++ /dev/null @@ -1,257 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) -# -# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# define raylib platform to compile for -# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB -# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() -PLATFORM ?= PLATFORM_DESKTOP - -# define NO to use OpenAL Soft as static library (shared by default) -SHARED_OPENAL ?= NO - -ifeq ($(PLATFORM),PLATFORM_WEB) - SHARED_OPENAL = NO -endif - -# define raylib directory for include and library -RAYLIB_PATH ?= C:\raylib\raylib - -# determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - LIBPATH=win32 - else - UNAMEOS:=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - LIBPATH=linux - else - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - LIBPATH=osx - endif - endif - endif -endif - -# define compiler: gcc for C program, define as g++ for C++ -ifeq ($(PLATFORM),PLATFORM_WEB) - # define emscripten compiler - CC = emcc -else -ifeq ($(PLATFORM_OS),OSX) - # define llvm compiler for mac - CC = clang -else - # define default gcc compiler - CC = gcc -endif -endif - -# define compiler flags: -# -O2 defines optimization level -# -Og enable debugging -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -fgnu89-inline declaring inline functions support (GCC optimized) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - CFLAGS = -O2 -s -Wall -std=c99 - endif - ifeq ($(PLATFORM_OS),LINUX) - CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE - endif - ifeq ($(PLATFORM_OS),OSX) - CFLAGS = -O2 -s -Wall -std=c99 - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=33554432 --profiling --preload-file resources - # -O2 # if used, also set --memory-init-file 0 - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # --preload-file file.res # embbed file.res resource into .data file -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline -endif -#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes - -# define raylib release directory for compiled library -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 - endif - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux - endif - ifeq ($(PLATFORM_OS),OSX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi -endif - -# define any directories containing required header files -INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -ifeq ($(PLATFORM),PLATFORM_RPI) - INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries headers - # GLFW3 - INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include - # OpenAL Soft - INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # you may optionally create this directory and install raylib - # and related headers there. Edit ../src/Makefile appropriately. - INCLUDES += -I/usr/local/include/raylib - endif - ifeq ($(PLATFORM_OS),OSX) - # additional directories for MacOS - endif -endif - -# define library paths containing required libs -LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_RPI) - LFLAGS += -L/opt/vc/lib -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # add standard directories for GNU/Linux - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries to link with - # GLFW3 - LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) - # OpenAL Soft - LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) - endif -endif - -# define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - # libraries for Debian GNU/Linux desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl - # on XWindow requires also below libraries - LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - else - ifeq ($(PLATFORM_OS),OSX) - # libraries for OSX 10.9 desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa - else - # libraries for Windows desktop compiling - # NOTE: GLFW3 and OpenAL Soft libraries should be installed - LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 - # if static OpenAL Soft required, define the corresponding libs - ifeq ($(SHARED_OPENAL),NO) - LIBS += -lopenal32 -lwinmm - CFLAGS += -Wl,-allow-multiple-definition - else - LIBS += -lopenal32dll - endif - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # libraries for Raspberry Pi compiling - # NOTE: OpenAL Soft library should be installed (libopenal1 package) - LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # NOTE: Set the correct path to libraylib.bc - LIBS = $(RAYLIB_RELEASE)/libraylib.bc -endif - -# define additional parameters and flags for windows -ifeq ($(PLATFORM_OS),WINDOWS) - # resources file contains windows exe icon - # -Wl,--subsystem,windows hides the console window - WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - EXT = .html - WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html -endif - -# define all screen object files required -SCREENS = \ - -# typing 'make' will invoke the default target entry -default: drturtle - -# compile program -drturtle: drturtle_final_web.c $(SCREENS) - $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - else - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f - else - del *.o *.exe /s - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -f *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - -# instead of defining every module one by one, we can define a pattern -# this pattern below will automatically compile every module defined on $(OBJS) -#%.exe : %.c -# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/just_do/Makefile b/games/just_do/Makefile new file mode 100644 index 00000000..6dc096fb --- /dev/null +++ b/games/just_do/Makefile @@ -0,0 +1,312 @@ +#************************************************************************************************** +# +# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) +# +# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) +# +# This software is provided "as-is", without any express or implied warranty. In no event +# will the authors be held liable for any damages arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, including commercial +# applications, and to alter it and redistribute it freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim that you +# wrote the original software. If you use this software in a product, an acknowledgment +# in the product documentation would be appreciated but is not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be misrepresented +# as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution. +# +#************************************************************************************************** + +.PHONY: all clean + +# define raylib platform to compile for +# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB +# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() +PLATFORM ?= PLATFORM_DESKTOP + +# define NO to use OpenAL Soft as static library (shared by default) +SHARED_OPENAL ?= NO + +ifeq ($(PLATFORM),PLATFORM_WEB) + SHARED_OPENAL = NO +endif + +# define raylib directory for include and library +RAYLIB_PATH ?= C:\raylib\raylib + +# determine PLATFORM_OS in case PLATFORM_DESKTOP selected +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows + ifeq ($(OS),Windows_NT) + PLATFORM_OS=WINDOWS + LIBPATH=win32 + else + UNAMEOS:=$(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS=LINUX + LIBPATH=linux + else + ifeq ($(UNAMEOS),Darwin) + PLATFORM_OS=OSX + LIBPATH=osx + endif + endif + endif +endif + +# define compiler: gcc for C program, define as g++ for C++ +ifeq ($(PLATFORM),PLATFORM_WEB) + # define emscripten compiler + CC = emcc +else +ifeq ($(PLATFORM_OS),OSX) + # define llvm compiler for mac + CC = clang +else + # define default gcc compiler + CC = gcc +endif +endif + +# define compiler flags: +# -O2 defines optimization level +# -Og enable debugging +# -s strip unnecessary data from build +# -Wall turns on most, but not all, compiler warnings +# -std=c99 defines C language mode (standard C from 1999 revision) +# -std=gnu99 defines C language mode (GNU C from 1999 revision) +# -fgnu89-inline declaring inline functions support (GCC optimized) +# -Wno-missing-braces ignore invalid warning (GCC bug 53119) +# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + CFLAGS = -O2 -s -Wall -std=c99 + endif + ifeq ($(PLATFORM_OS),LINUX) + CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE + endif + ifeq ($(PLATFORM_OS),OSX) + CFLAGS = -O2 -s -Wall -std=c99 + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources + # -O2 # if used, also set --memory-init-file 0 + # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) + # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing + # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # --preload-file file.res # embbed file.res resource into .data file +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline +endif +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define raylib release directory for compiled library +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 + endif + ifeq ($(PLATFORM_OS),LINUX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux + endif + ifeq ($(PLATFORM_OS),OSX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi +endif + +# define any directories containing required header files +INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external + +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries headers + # GLFW3 + INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include + # OpenAL Soft + INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include + endif + ifeq ($(PLATFORM_OS),LINUX) + # you may optionally create this directory and install raylib + # and related headers there. Edit ../src/Makefile appropriately. + INCLUDES += -I/usr/local/include/raylib + endif + ifeq ($(PLATFORM_OS),OSX) + # additional directories for MacOS + endif +endif + +# define library paths containing required libs +LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src + +ifeq ($(PLATFORM),PLATFORM_RPI) + LFLAGS += -L/opt/vc/lib +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # add standard directories for GNU/Linux + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries to link with + # GLFW3 + LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) + # OpenAL Soft + LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) + endif +endif + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),LINUX) + # libraries for Debian GNU/Linux desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl + # on XWindow requires also below libraries + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + else + ifeq ($(PLATFORM_OS),OSX) + # libraries for OSX 10.9 desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa + else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 + # if static OpenAL Soft required, define the corresponding libs + ifeq ($(SHARED_OPENAL),NO) + LIBS += -lopenal32 -lwinmm + CFLAGS += -Wl,-allow-multiple-definition + else + LIBS += -lopenal32dll + endif + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + # NOTE: Set the correct path to libraylib.bc + LIBS = $(RAYLIB_RELEASE)/libraylib.bc +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM_OS),WINDOWS) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows +endif + +ifeq ($(PLATFORM),PLATFORM_WEB) + EXT = .html + WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html +endif + +# define all screen object files required +SCREENS = \ + screens/screen_logo.o \ + screens/screen_level00.o \ + screens/screen_level01.o \ + screens/screen_level02.o \ + screens/screen_level03.o \ + screens/screen_level04.o \ + screens/screen_level05.o \ + screens/screen_level06.o \ + screens/screen_level07.o \ + screens/screen_level08.o \ + screens/screen_level09.o \ + +# typing 'make' will invoke the default target entry +default: just_do + +# compile program +just_do: just_do.c $(SCREENS) + $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile screen LOGO +screens/screen_logo.o: screens/screen_logo.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL00 +screens/screen_level00.o: screens/screen_level00.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL01 +screens/screen_level01.o: screens/screen_level01.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL02 +screens/screen_level02.o: screens/screen_level02.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL03 +screens/screen_level03.o: screens/screen_level03.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL04 +screens/screen_level04.o: screens/screen_level04.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL05 +screens/screen_level05.o: screens/screen_level05.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL06 +screens/screen_level06.o: screens/screen_level06.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL07 +screens/screen_level07.o: screens/screen_level07.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL08 +screens/screen_level08.o: screens/screen_level08.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LEVEL09 +screens/screen_level09.o: screens/screen_level09.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -delete + rm -f *.o + else + ifeq ($(PLATFORM_OS),LINUX) + find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f + else + del *.o *.exe /s + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + find . -type f -executable -delete + rm -f *.o +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + del *.o *.html *.js +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/just_do/makefile b/games/just_do/makefile deleted file mode 100644 index 6dc096fb..00000000 --- a/games/just_do/makefile +++ /dev/null @@ -1,312 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) -# -# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# define raylib platform to compile for -# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB -# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() -PLATFORM ?= PLATFORM_DESKTOP - -# define NO to use OpenAL Soft as static library (shared by default) -SHARED_OPENAL ?= NO - -ifeq ($(PLATFORM),PLATFORM_WEB) - SHARED_OPENAL = NO -endif - -# define raylib directory for include and library -RAYLIB_PATH ?= C:\raylib\raylib - -# determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - LIBPATH=win32 - else - UNAMEOS:=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - LIBPATH=linux - else - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - LIBPATH=osx - endif - endif - endif -endif - -# define compiler: gcc for C program, define as g++ for C++ -ifeq ($(PLATFORM),PLATFORM_WEB) - # define emscripten compiler - CC = emcc -else -ifeq ($(PLATFORM_OS),OSX) - # define llvm compiler for mac - CC = clang -else - # define default gcc compiler - CC = gcc -endif -endif - -# define compiler flags: -# -O2 defines optimization level -# -Og enable debugging -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -fgnu89-inline declaring inline functions support (GCC optimized) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - CFLAGS = -O2 -s -Wall -std=c99 - endif - ifeq ($(PLATFORM_OS),LINUX) - CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE - endif - ifeq ($(PLATFORM_OS),OSX) - CFLAGS = -O2 -s -Wall -std=c99 - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources - # -O2 # if used, also set --memory-init-file 0 - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # --preload-file file.res # embbed file.res resource into .data file -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline -endif -#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes - -# define raylib release directory for compiled library -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 - endif - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux - endif - ifeq ($(PLATFORM_OS),OSX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi -endif - -# define any directories containing required header files -INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -ifeq ($(PLATFORM),PLATFORM_RPI) - INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries headers - # GLFW3 - INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include - # OpenAL Soft - INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # you may optionally create this directory and install raylib - # and related headers there. Edit ../src/Makefile appropriately. - INCLUDES += -I/usr/local/include/raylib - endif - ifeq ($(PLATFORM_OS),OSX) - # additional directories for MacOS - endif -endif - -# define library paths containing required libs -LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_RPI) - LFLAGS += -L/opt/vc/lib -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # add standard directories for GNU/Linux - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries to link with - # GLFW3 - LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) - # OpenAL Soft - LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) - endif -endif - -# define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - # libraries for Debian GNU/Linux desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl - # on XWindow requires also below libraries - LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - else - ifeq ($(PLATFORM_OS),OSX) - # libraries for OSX 10.9 desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa - else - # libraries for Windows desktop compiling - # NOTE: GLFW3 and OpenAL Soft libraries should be installed - LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 - # if static OpenAL Soft required, define the corresponding libs - ifeq ($(SHARED_OPENAL),NO) - LIBS += -lopenal32 -lwinmm - CFLAGS += -Wl,-allow-multiple-definition - else - LIBS += -lopenal32dll - endif - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # libraries for Raspberry Pi compiling - # NOTE: OpenAL Soft library should be installed (libopenal1 package) - LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # NOTE: Set the correct path to libraylib.bc - LIBS = $(RAYLIB_RELEASE)/libraylib.bc -endif - -# define additional parameters and flags for windows -ifeq ($(PLATFORM_OS),WINDOWS) - # resources file contains windows exe icon - # -Wl,--subsystem,windows hides the console window - WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - EXT = .html - WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html -endif - -# define all screen object files required -SCREENS = \ - screens/screen_logo.o \ - screens/screen_level00.o \ - screens/screen_level01.o \ - screens/screen_level02.o \ - screens/screen_level03.o \ - screens/screen_level04.o \ - screens/screen_level05.o \ - screens/screen_level06.o \ - screens/screen_level07.o \ - screens/screen_level08.o \ - screens/screen_level09.o \ - -# typing 'make' will invoke the default target entry -default: just_do - -# compile program -just_do: just_do.c $(SCREENS) - $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile screen LOGO -screens/screen_logo.o: screens/screen_logo.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL00 -screens/screen_level00.o: screens/screen_level00.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL01 -screens/screen_level01.o: screens/screen_level01.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL02 -screens/screen_level02.o: screens/screen_level02.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL03 -screens/screen_level03.o: screens/screen_level03.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL04 -screens/screen_level04.o: screens/screen_level04.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL05 -screens/screen_level05.o: screens/screen_level05.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL06 -screens/screen_level06.o: screens/screen_level06.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL07 -screens/screen_level07.o: screens/screen_level07.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL08 -screens/screen_level08.o: screens/screen_level08.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LEVEL09 -screens/screen_level09.o: screens/screen_level09.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - else - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f - else - del *.o *.exe /s - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -f *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - -# instead of defining every module one by one, we can define a pattern -# this pattern below will automatically compile every module defined on $(OBJS) -#%.exe : %.c -# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/light_my_ritual/Makefile b/games/light_my_ritual/Makefile new file mode 100644 index 00000000..7bede523 --- /dev/null +++ b/games/light_my_ritual/Makefile @@ -0,0 +1,272 @@ +#************************************************************************************************** +# +# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) +# +# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) +# +# This software is provided "as-is", without any express or implied warranty. In no event +# will the authors be held liable for any damages arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, including commercial +# applications, and to alter it and redistribute it freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim that you +# wrote the original software. If you use this software in a product, an acknowledgment +# in the product documentation would be appreciated but is not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be misrepresented +# as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution. +# +#************************************************************************************************** + +.PHONY: all clean + +# define raylib platform to compile for +# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB +# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() +PLATFORM ?= PLATFORM_DESKTOP + +# define NO to use OpenAL Soft as static library (shared by default) +SHARED_OPENAL ?= NO + +ifeq ($(PLATFORM),PLATFORM_WEB) + SHARED_OPENAL = NO +endif + +# define raylib directory for include and library +RAYLIB_PATH ?= C:\raylib\raylib + +# determine PLATFORM_OS in case PLATFORM_DESKTOP selected +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows + ifeq ($(OS),Windows_NT) + PLATFORM_OS=WINDOWS + LIBPATH=win32 + else + UNAMEOS:=$(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS=LINUX + LIBPATH=linux + else + ifeq ($(UNAMEOS),Darwin) + PLATFORM_OS=OSX + LIBPATH=osx + endif + endif + endif +endif + +# define compiler: gcc for C program, define as g++ for C++ +ifeq ($(PLATFORM),PLATFORM_WEB) + # define emscripten compiler + CC = emcc +else +ifeq ($(PLATFORM_OS),OSX) + # define llvm compiler for mac + CC = clang +else + # define default gcc compiler + CC = gcc +endif +endif + +# define compiler flags: +# -O2 defines optimization level +# -Og enable debugging +# -s strip unnecessary data from build +# -Wall turns on most, but not all, compiler warnings +# -std=c99 defines C language mode (standard C from 1999 revision) +# -std=gnu99 defines C language mode (GNU C from 1999 revision) +# -fgnu89-inline declaring inline functions support (GCC optimized) +# -Wno-missing-braces ignore invalid warning (GCC bug 53119) +# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + CFLAGS = -O2 -s -Wall -std=c99 + endif + ifeq ($(PLATFORM_OS),LINUX) + CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE + endif + ifeq ($(PLATFORM_OS),OSX) + CFLAGS = -O2 -s -Wall -std=c99 + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources -s TOTAL_MEMORY=33554432 + # -O2 # if used, also set --memory-init-file 0 + # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) + # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing + # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # --preload-file file.res # embbed file.res resource into .data file +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline +endif +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define raylib release directory for compiled library +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 + endif + ifeq ($(PLATFORM_OS),LINUX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux + endif + ifeq ($(PLATFORM_OS),OSX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi +endif + +# define any directories containing required header files +INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external + +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries headers + # GLFW3 + INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include + # OpenAL Soft + INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include + endif + ifeq ($(PLATFORM_OS),LINUX) + # you may optionally create this directory and install raylib + # and related headers there. Edit ../src/Makefile appropriately. + INCLUDES += -I/usr/local/include/raylib + endif + ifeq ($(PLATFORM_OS),OSX) + # additional directories for MacOS + endif +endif + +# define library paths containing required libs +LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src + +ifeq ($(PLATFORM),PLATFORM_RPI) + LFLAGS += -L/opt/vc/lib +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # add standard directories for GNU/Linux + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries to link with + # GLFW3 + LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) + # OpenAL Soft + LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) + endif +endif + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),LINUX) + # libraries for Debian GNU/Linux desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl + # on XWindow requires also below libraries + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + else + ifeq ($(PLATFORM_OS),OSX) + # libraries for OSX 10.9 desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa + else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 + # if static OpenAL Soft required, define the corresponding libs + ifeq ($(SHARED_OPENAL),NO) + LIBS += -lopenal32 -lwinmm + CFLAGS += -Wl,-allow-multiple-definition + else + LIBS += -lopenal32dll + endif + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + # NOTE: Set the correct path to libraylib.bc + LIBS = $(RAYLIB_RELEASE)/libraylib.bc +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM_OS),WINDOWS) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows +endif + +ifeq ($(PLATFORM),PLATFORM_WEB) + EXT = .html + WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html +endif + +# define all screen object files required +SCREENS = \ + screens/screen_logo_raylib.o \ + screens/screen_title.o \ + screens/screen_gameplay.o \ + +# typing 'make' will invoke the default target entry +default: light_my_ritual + +# compile program +light_my_ritual: light_my_ritual.c $(SCREENS) + $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile screen LOGO raylib +screens/screen_logo_raylib.o: screens/screen_logo_raylib.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen TITLE +screens/screen_title.o: screens/screen_title.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen ENDING +screens/screen_gameplay.o: screens/screen_gameplay.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -delete + rm -f *.o + else + ifeq ($(PLATFORM_OS),LINUX) + find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f + else + del *.o *.exe /s + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + find . -type f -executable -delete + rm -f *.o +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + del *.o *.html *.js +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/light_my_ritual/makefile b/games/light_my_ritual/makefile deleted file mode 100644 index 7bede523..00000000 --- a/games/light_my_ritual/makefile +++ /dev/null @@ -1,272 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) -# -# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# define raylib platform to compile for -# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB -# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() -PLATFORM ?= PLATFORM_DESKTOP - -# define NO to use OpenAL Soft as static library (shared by default) -SHARED_OPENAL ?= NO - -ifeq ($(PLATFORM),PLATFORM_WEB) - SHARED_OPENAL = NO -endif - -# define raylib directory for include and library -RAYLIB_PATH ?= C:\raylib\raylib - -# determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - LIBPATH=win32 - else - UNAMEOS:=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - LIBPATH=linux - else - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - LIBPATH=osx - endif - endif - endif -endif - -# define compiler: gcc for C program, define as g++ for C++ -ifeq ($(PLATFORM),PLATFORM_WEB) - # define emscripten compiler - CC = emcc -else -ifeq ($(PLATFORM_OS),OSX) - # define llvm compiler for mac - CC = clang -else - # define default gcc compiler - CC = gcc -endif -endif - -# define compiler flags: -# -O2 defines optimization level -# -Og enable debugging -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -fgnu89-inline declaring inline functions support (GCC optimized) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - CFLAGS = -O2 -s -Wall -std=c99 - endif - ifeq ($(PLATFORM_OS),LINUX) - CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE - endif - ifeq ($(PLATFORM_OS),OSX) - CFLAGS = -O2 -s -Wall -std=c99 - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources -s TOTAL_MEMORY=33554432 - # -O2 # if used, also set --memory-init-file 0 - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # --preload-file file.res # embbed file.res resource into .data file -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline -endif -#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes - -# define raylib release directory for compiled library -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 - endif - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux - endif - ifeq ($(PLATFORM_OS),OSX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi -endif - -# define any directories containing required header files -INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -ifeq ($(PLATFORM),PLATFORM_RPI) - INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries headers - # GLFW3 - INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include - # OpenAL Soft - INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # you may optionally create this directory and install raylib - # and related headers there. Edit ../src/Makefile appropriately. - INCLUDES += -I/usr/local/include/raylib - endif - ifeq ($(PLATFORM_OS),OSX) - # additional directories for MacOS - endif -endif - -# define library paths containing required libs -LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_RPI) - LFLAGS += -L/opt/vc/lib -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # add standard directories for GNU/Linux - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries to link with - # GLFW3 - LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) - # OpenAL Soft - LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) - endif -endif - -# define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - # libraries for Debian GNU/Linux desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl - # on XWindow requires also below libraries - LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - else - ifeq ($(PLATFORM_OS),OSX) - # libraries for OSX 10.9 desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa - else - # libraries for Windows desktop compiling - # NOTE: GLFW3 and OpenAL Soft libraries should be installed - LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 - # if static OpenAL Soft required, define the corresponding libs - ifeq ($(SHARED_OPENAL),NO) - LIBS += -lopenal32 -lwinmm - CFLAGS += -Wl,-allow-multiple-definition - else - LIBS += -lopenal32dll - endif - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # libraries for Raspberry Pi compiling - # NOTE: OpenAL Soft library should be installed (libopenal1 package) - LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # NOTE: Set the correct path to libraylib.bc - LIBS = $(RAYLIB_RELEASE)/libraylib.bc -endif - -# define additional parameters and flags for windows -ifeq ($(PLATFORM_OS),WINDOWS) - # resources file contains windows exe icon - # -Wl,--subsystem,windows hides the console window - WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - EXT = .html - WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html -endif - -# define all screen object files required -SCREENS = \ - screens/screen_logo_raylib.o \ - screens/screen_title.o \ - screens/screen_gameplay.o \ - -# typing 'make' will invoke the default target entry -default: light_my_ritual - -# compile program -light_my_ritual: light_my_ritual.c $(SCREENS) - $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile screen LOGO raylib -screens/screen_logo_raylib.o: screens/screen_logo_raylib.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen TITLE -screens/screen_title.o: screens/screen_title.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen ENDING -screens/screen_gameplay.o: screens/screen_gameplay.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - else - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f - else - del *.o *.exe /s - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -f *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - -# instead of defining every module one by one, we can define a pattern -# this pattern below will automatically compile every module defined on $(OBJS) -#%.exe : %.c -# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/skully_escape/Makefile b/games/skully_escape/Makefile new file mode 100644 index 00000000..70f7f5a3 --- /dev/null +++ b/games/skully_escape/Makefile @@ -0,0 +1,322 @@ +#************************************************************************************************** +# +# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) +# +# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) +# +# This software is provided "as-is", without any express or implied warranty. In no event +# will the authors be held liable for any damages arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, including commercial +# applications, and to alter it and redistribute it freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim that you +# wrote the original software. If you use this software in a product, an acknowledgment +# in the product documentation would be appreciated but is not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be misrepresented +# as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution. +# +#************************************************************************************************** + +.PHONY: all clean + +# define raylib platform to compile for +# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB +# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() +PLATFORM ?= PLATFORM_DESKTOP + +# define NO to use OpenAL Soft as static library (shared by default) +SHARED_OPENAL ?= NO + +ifeq ($(PLATFORM),PLATFORM_WEB) + SHARED_OPENAL = NO +endif + +# define raylib directory for include and library +RAYLIB_PATH ?= C:\raylib\raylib + +# determine PLATFORM_OS in case PLATFORM_DESKTOP selected +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows + ifeq ($(OS),Windows_NT) + PLATFORM_OS=WINDOWS + LIBPATH=win32 + else + UNAMEOS:=$(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS=LINUX + LIBPATH=linux + else + ifeq ($(UNAMEOS),Darwin) + PLATFORM_OS=OSX + LIBPATH=osx + endif + endif + endif +endif + +# define compiler: gcc for C program, define as g++ for C++ +ifeq ($(PLATFORM),PLATFORM_WEB) + # define emscripten compiler + CC = emcc +else +ifeq ($(PLATFORM_OS),OSX) + # define llvm compiler for mac + CC = clang +else + # define default gcc compiler + CC = gcc +endif +endif + +# define compiler flags: +# -O2 defines optimization level +# -Og enable debugging +# -s strip unnecessary data from build +# -Wall turns on most, but not all, compiler warnings +# -std=c99 defines C language mode (standard C from 1999 revision) +# -std=gnu99 defines C language mode (GNU C from 1999 revision) +# -fgnu89-inline declaring inline functions support (GCC optimized) +# -Wno-missing-braces ignore invalid warning (GCC bug 53119) +# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + CFLAGS = -O2 -s -Wall -std=c99 + endif + ifeq ($(PLATFORM_OS),LINUX) + CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE + endif + ifeq ($(PLATFORM_OS),OSX) + CFLAGS = -O2 -s -Wall -std=c99 + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources + # -O2 # if used, also set --memory-init-file 0 + # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) + # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing + # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # --preload-file file.res # embbed file.res resource into .data file +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline +endif +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define raylib release directory for compiled library +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 + endif + ifeq ($(PLATFORM_OS),LINUX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux + endif + ifeq ($(PLATFORM_OS),OSX) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx + endif +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi +endif + +# define any directories containing required header files +INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external + +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries headers + # GLFW3 + INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include + # OpenAL Soft + INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include + endif + ifeq ($(PLATFORM_OS),LINUX) + # you may optionally create this directory and install raylib + # and related headers there. Edit ../src/Makefile appropriately. + INCLUDES += -I/usr/local/include/raylib + endif + ifeq ($(PLATFORM_OS),OSX) + # additional directories for MacOS + endif +endif + +# define library paths containing required libs +LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src + +ifeq ($(PLATFORM),PLATFORM_RPI) + LFLAGS += -L/opt/vc/lib +endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # add standard directories for GNU/Linux + ifeq ($(PLATFORM_OS),WINDOWS) + # external libraries to link with + # GLFW3 + LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) + # OpenAL Soft + LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) + endif +endif + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),LINUX) + # libraries for Debian GNU/Linux desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl + # on XWindow requires also below libraries + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + else + ifeq ($(PLATFORM_OS),OSX) + # libraries for OSX 10.9 desktop compiling + # requires the following packages: + # libglfw3-dev libopenal-dev libegl1-mesa-dev + LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa + else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 + # if static OpenAL Soft required, define the corresponding libs + ifeq ($(SHARED_OPENAL),NO) + LIBS += -lopenal32 -lwinmm + CFLAGS += -Wl,-allow-multiple-definition + else + LIBS += -lopenal32dll + endif + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + # NOTE: Set the correct path to libraylib.bc + LIBS = $(RAYLIB_RELEASE)/libraylib.bc +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM_OS),WINDOWS) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows +endif + +ifeq ($(PLATFORM),PLATFORM_WEB) + EXT = .html + WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html +endif + +# define all screen object files required +SCREENS = \ + screens/screen_logo.o \ + screens/screen_logo_raylib.o \ + screens/screen_title.o \ + screens/screen_attic.o \ + screens/screen_aisle01.o \ + screens/screen_aisle02.o \ + screens/screen_armory.o \ + screens/screen_livingroom.o \ + screens/screen_kitchen.o \ + screens/screen_bathroom.o \ + screens/screen_ending.o \ + player.o \ + monster.o \ + +# typing 'make' will invoke the default target entry +default: skully_escape + +# compile program +skully_escape: skully_escape.c $(SCREENS) + $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) + +# compile screen LOGO +screens/screen_logo.o: screens/screen_logo.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LOGO raylib +screens/screen_logo_raylib.o: screens/screen_logo_raylib.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen TITLE +screens/screen_title.o: screens/screen_title.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen ATTIC +screens/screen_attic.o: screens/screen_attic.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen AISLE01 +screens/screen_aisle01.o: screens/screen_aisle01.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen AISLE02 +screens/screen_aisle02.o: screens/screen_aisle02.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen BATHROOM +screens/screen_bathroom.o: screens/screen_bathroom.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LIVINGROOM +screens/screen_livingroom.o: screens/screen_livingroom.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen KITCHEN +screens/screen_kitchen.o: screens/screen_kitchen.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen ARMORY +screens/screen_armory.o: screens/screen_armory.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen ENDING +screens/screen_ending.o: screens/screen_ending.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LOGO +player.o: player.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen LOGO +monster.o: monster.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -delete + rm -f *.o + else + ifeq ($(PLATFORM_OS),LINUX) + find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f + else + del *.o *.exe /s + endif + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + find . -type f -executable -delete + rm -f *.o +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + del *.o *.html *.js +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/games/skully_escape/makefile b/games/skully_escape/makefile deleted file mode 100644 index 70f7f5a3..00000000 --- a/games/skully_escape/makefile +++ /dev/null @@ -1,322 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) -# -# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# define raylib platform to compile for -# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB -# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() -PLATFORM ?= PLATFORM_DESKTOP - -# define NO to use OpenAL Soft as static library (shared by default) -SHARED_OPENAL ?= NO - -ifeq ($(PLATFORM),PLATFORM_WEB) - SHARED_OPENAL = NO -endif - -# define raylib directory for include and library -RAYLIB_PATH ?= C:\raylib\raylib - -# determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - LIBPATH=win32 - else - UNAMEOS:=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - LIBPATH=linux - else - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - LIBPATH=osx - endif - endif - endif -endif - -# define compiler: gcc for C program, define as g++ for C++ -ifeq ($(PLATFORM),PLATFORM_WEB) - # define emscripten compiler - CC = emcc -else -ifeq ($(PLATFORM_OS),OSX) - # define llvm compiler for mac - CC = clang -else - # define default gcc compiler - CC = gcc -endif -endif - -# define compiler flags: -# -O2 defines optimization level -# -Og enable debugging -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -fgnu89-inline declaring inline functions support (GCC optimized) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - CFLAGS = -O2 -s -Wall -std=c99 - endif - ifeq ($(PLATFORM_OS),LINUX) - CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE - endif - ifeq ($(PLATFORM_OS),OSX) - CFLAGS = -O2 -s -Wall -std=c99 - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources - # -O2 # if used, also set --memory-init-file 0 - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # --preload-file file.res # embbed file.res resource into .data file -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline -endif -#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes - -# define raylib release directory for compiled library -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 - endif - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux - endif - ifeq ($(PLATFORM_OS),OSX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi -endif - -# define any directories containing required header files -INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -ifeq ($(PLATFORM),PLATFORM_RPI) - INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries headers - # GLFW3 - INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include - # OpenAL Soft - INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # you may optionally create this directory and install raylib - # and related headers there. Edit ../src/Makefile appropriately. - INCLUDES += -I/usr/local/include/raylib - endif - ifeq ($(PLATFORM_OS),OSX) - # additional directories for MacOS - endif -endif - -# define library paths containing required libs -LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_RPI) - LFLAGS += -L/opt/vc/lib -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # add standard directories for GNU/Linux - ifeq ($(PLATFORM_OS),WINDOWS) - # external libraries to link with - # GLFW3 - LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) - # OpenAL Soft - LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) - endif -endif - -# define any libraries to link into executable -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - # libraries for Debian GNU/Linux desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl - # on XWindow requires also below libraries - LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - else - ifeq ($(PLATFORM_OS),OSX) - # libraries for OSX 10.9 desktop compiling - # requires the following packages: - # libglfw3-dev libopenal-dev libegl1-mesa-dev - LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa - else - # libraries for Windows desktop compiling - # NOTE: GLFW3 and OpenAL Soft libraries should be installed - LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 - # if static OpenAL Soft required, define the corresponding libs - ifeq ($(SHARED_OPENAL),NO) - LIBS += -lopenal32 -lwinmm - CFLAGS += -Wl,-allow-multiple-definition - else - LIBS += -lopenal32dll - endif - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # libraries for Raspberry Pi compiling - # NOTE: OpenAL Soft library should be installed (libopenal1 package) - LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # NOTE: Set the correct path to libraylib.bc - LIBS = $(RAYLIB_RELEASE)/libraylib.bc -endif - -# define additional parameters and flags for windows -ifeq ($(PLATFORM_OS),WINDOWS) - # resources file contains windows exe icon - # -Wl,--subsystem,windows hides the console window - WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - EXT = .html - WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html -endif - -# define all screen object files required -SCREENS = \ - screens/screen_logo.o \ - screens/screen_logo_raylib.o \ - screens/screen_title.o \ - screens/screen_attic.o \ - screens/screen_aisle01.o \ - screens/screen_aisle02.o \ - screens/screen_armory.o \ - screens/screen_livingroom.o \ - screens/screen_kitchen.o \ - screens/screen_bathroom.o \ - screens/screen_ending.o \ - player.o \ - monster.o \ - -# typing 'make' will invoke the default target entry -default: skully_escape - -# compile program -skully_escape: skully_escape.c $(SCREENS) - $(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) - -# compile screen LOGO -screens/screen_logo.o: screens/screen_logo.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LOGO raylib -screens/screen_logo_raylib.o: screens/screen_logo_raylib.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen TITLE -screens/screen_title.o: screens/screen_title.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen ATTIC -screens/screen_attic.o: screens/screen_attic.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen AISLE01 -screens/screen_aisle01.o: screens/screen_aisle01.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen AISLE02 -screens/screen_aisle02.o: screens/screen_aisle02.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen BATHROOM -screens/screen_bathroom.o: screens/screen_bathroom.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LIVINGROOM -screens/screen_livingroom.o: screens/screen_livingroom.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen KITCHEN -screens/screen_kitchen.o: screens/screen_kitchen.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen ARMORY -screens/screen_armory.o: screens/screen_armory.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen ENDING -screens/screen_ending.o: screens/screen_ending.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LOGO -player.o: player.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# compile screen LOGO -monster.o: monster.c - $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) - -# clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - else - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f - else - del *.o *.exe /s - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -f *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - -# instead of defining every module one by one, we can define a pattern -# this pattern below will automatically compile every module defined on $(OBJS) -#%.exe : %.c -# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) -- cgit v1.2.3 From dd7b64a53670584a6e8ac2943531a51b967db8a9 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 18:36:38 +0200 Subject: Simplify README Move raylib history to another file --- HISTORY.md | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 169 ++----------------------------------------------------------- 2 files changed, 170 insertions(+), 164 deletions(-) create mode 100644 HISTORY.md diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 00000000..c5fd1c99 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,165 @@ + + +history +------- + +I've developed videogames for some years and 4 years ago I started teaching videogames development +to young people with artistic profile, most of them had never written a single line of code. + +I started with C language basis and, after searching for the most simple and easy-to-use library to teach +videogames programming, I found WinBGI; it was great and it worked very well with students, in just a +couple of weeks that people that had never written a single line of code were able to program (and understand) +a simple PONG and some of them even a BREAKOUT! + +But WinBGI was not the clearer and most organized lib. There were a lot of things I found useless and +confusing and some function names were not clear enough for most of the students; not to mention points +like no transparencies support or no hardware acceleration. + +So, I decided to create my own lib, hardware accelerated, clear function names, quite organized, well structured, +plain C coding and, the most important, primarily intended to LEARN videogames programming. + +I've coded quite a lot in C# and XNA and I really love it (in fact, my students learn C# after C), +so, I decided to use C# language notation and XNA naming conventions. That way, students can jump from +raylib to XNA, MonoGame or similar libs extremely easily. + +raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013. + +Enjoy it. + +notes on raylib 1.1 +------------------- + +On April 2014, after 6 month of first raylib release, raylib 1.1 has been released. This new version presents a +complete internal redesign of the library to support OpenGL 1.1, OpenGL 3.3+ and OpenGL ES 2.0. + +A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translates raylib-OpenGL-style +immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define. + +[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes +a bunch of useful functions for 3d-math with vectors, matrices and quaternions. + +Some other big changes of this new version have been the support for OGG files loading and stream playing, and the +support of DDS texture files (compressed and uncompressed) along with mipmaps support. + +Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1. + +notes on raylib 1.2 +------------------- + +On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a +complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/). + +It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the user. +On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input +system has been written from scratch. + +A new display initialization system has been created to support multiple resolutions, adding black bars if required; +user only defines desired screen size and it gets properly displayed. + +Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode). + +Lots of code changes and lot of testing have concluded in this amazing new raylib 1.2. + +In December 2014, new raylib 1.2.2 was published with support to compile directly for web (html5) using [emscripten](http://kripken.github.io/emscripten-site/) and [asm.js](http://asmjs.org/). + +notes on raylib 1.3 +------------------- + +On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality, +improves tremendously textures module and also provides some new modules (camera system, gestures system, IMGUI). + +Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be +attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included +in this release, check raylib/shaders folder. + +Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files. +A brand new [camera](https://github.com/raysan5/raylib/blob/develop/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). +Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_first_person.c). + +New [gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs. + +[raygui](https://github.com/raysan5/raylib/blob/develop/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces, +primary intended for tools development. It's still in experimental state but already fully functional. + +Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features. + +Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3. + +notes on raylib 1.4 +------------------- + +On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version, +lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added. + +First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image. +Now a basic image processing can be done before converting the image to texture for usage. + +SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library). +Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file. + +New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional. +Module comes with some usage examples for basic jump and level interaction and also force-based physic movements. + +[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline. + +[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. +This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code. + +Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). +Gamepad support has also been added (experimental). + +Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions, +and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported). +A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation. + +Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn +how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris. + +Lots of code changes and lots of hours of hard work have concluded in this amazing new raylib 1.4. + +notes on raylib 1.5 +------------------- + +On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new version is the biggest boost of the library until now, lots of parts of the library have been redesigned, lots of bugs have been solved and some **AMAZING** new features have been added. + +VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameteres, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/develop/examples/core_oculus_rift.c). + +New materials system: now raylib supports standard material properties for 3D models, including diffuse-ambient-specular colors and diffuse-normal-specular textures. Just assign values to standard material and everything is processed internally. + +New lighting system: added support for up to 8 configurable lights and 3 light types: **point**, **directional** and **spot** lights. Just create a light, configure its parameters and raylib manages render internally for every 3d object using standard material. + +Complete gamepad support on Raspberry Pi: Gamepad system has been completely redesigned. Now multiple gamepads can be easily configured and used; gamepad data is read and processed in raw mode in a second thread. + +Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/develop/examples/physics_basic_rigidbody.c). Performance has also been singnificantly improved, now physic objects are managed internally in a second thread. + +Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck. + +Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/develop/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/develop/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms. + +This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/develop/CHANGELOG) file for a more detailed list of changes. + +Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/develop/examples/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/develop/examples/audio_standalone.c) raylib modules as standalone libraries. + +Lots of code changes (+400 commits) and lots of hours of hard work have concluded in this amazing new raylib 1.5. + +notes on raylib 1.6 +------------------- + +On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new version represents another big review of the library and includes some interesting additions. This version conmmemorates raylib 3rd anniversary (raylib 1.0 was published on November 2013) and it is a stepping stone for raylib future. raylib roadmap has been reviewed and redefined to focus on its primary objective: create a simple and easy-to-use library to learn videogames programming. Some of the new features: + +Complete raylib Lua binding. All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality. + +Completely redesigned audio module. Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. FLAC file format support has also been added. In the same line, OpenAL Soft backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more! + +Physac module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by @victorfisac, multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing! + +Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples. + +Improved Gamepad support on Windows and Raspberry Pi with the addition of new functions for custom gamepad configurations but supporting by default PS3 and Xbox-based gamepads. + +Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support. + +Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured Visual Studio C++ 2015 solution with raylib project and C/C++ examples for users that prefer that professional IDE and compiler. + +New examples, new functions, complete code-base review, multiple bugs corrected... this is raylib 1.6. Enjoy making games. + diff --git a/README.md b/README.md index b868172e..10c4b935 100644 --- a/README.md +++ b/README.md @@ -11,170 +11,6 @@ NOTE for ADVENTURERS: raylib is a programming library to learn videogames progra no fancy interface, no visual helpers, no auto-debugging... just coding in the most pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html) -history -------- - -I've developed videogames for some years and 4 years ago I started teaching videogames development -to young people with artistic profile, most of them had never written a single line of code. - -I started with C language basis and, after searching for the most simple and easy-to-use library to teach -videogames programming, I found WinBGI; it was great and it worked very well with students, in just a -couple of weeks that people that had never written a single line of code were able to program (and understand) -a simple PONG and some of them even a BREAKOUT! - -But WinBGI was not the clearer and most organized lib. There were a lot of things I found useless and -confusing and some function names were not clear enough for most of the students; not to mention points -like no transparencies support or no hardware acceleration. - -So, I decided to create my own lib, hardware accelerated, clear function names, quite organized, well structured, -plain C coding and, the most important, primarily intended to LEARN videogames programming. - -I've coded quite a lot in C# and XNA and I really love it (in fact, my students learn C# after C), -so, I decided to use C# language notation and XNA naming conventions. That way, students can jump from -raylib to XNA, MonoGame or similar libs extremely easily. - -raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013. - -Enjoy it. - -notes on raylib 1.1 -------------------- - -On April 2014, after 6 month of first raylib release, raylib 1.1 has been released. This new version presents a -complete internal redesign of the library to support OpenGL 1.1, OpenGL 3.3+ and OpenGL ES 2.0. - -A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translates raylib-OpenGL-style -immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define. - -[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes -a bunch of useful functions for 3d-math with vectors, matrices and quaternions. - -Some other big changes of this new version have been the support for OGG files loading and stream playing, and the -support of DDS texture files (compressed and uncompressed) along with mipmaps support. - -Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1. - -notes on raylib 1.2 -------------------- - -On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a -complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/). - -It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the user. -On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input -system has been written from scratch. - -A new display initialization system has been created to support multiple resolutions, adding black bars if required; -user only defines desired screen size and it gets properly displayed. - -Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode). - -Lots of code changes and lot of testing have concluded in this amazing new raylib 1.2. - -In December 2014, new raylib 1.2.2 was published with support to compile directly for web (html5) using [emscripten](http://kripken.github.io/emscripten-site/) and [asm.js](http://asmjs.org/). - -notes on raylib 1.3 -------------------- - -On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality, -improves tremendously textures module and also provides some new modules (camera system, gestures system, IMGUI). - -Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be -attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included -in this release, check raylib/shaders folder. - -Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files. -A brand new [camera](https://github.com/raysan5/raylib/blob/develop/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). -Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_first_person.c). - -New [gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs. - -[raygui](https://github.com/raysan5/raylib/blob/develop/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces, -primary intended for tools development. It's still in experimental state but already fully functional. - -Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features. - -Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3. - -notes on raylib 1.4 -------------------- - -On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version, -lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added. - -First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image. -Now a basic image processing can be done before converting the image to texture for usage. - -SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library). -Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file. - -New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional. -Module comes with some usage examples for basic jump and level interaction and also force-based physic movements. - -[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline. - -[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. -This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code. - -Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). -Gamepad support has also been added (experimental). - -Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions, -and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported). -A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation. - -Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn -how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris. - -Lots of code changes and lots of hours of hard work have concluded in this amazing new raylib 1.4. - -notes on raylib 1.5 -------------------- - -On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new version is the biggest boost of the library until now, lots of parts of the library have been redesigned, lots of bugs have been solved and some **AMAZING** new features have been added. - -VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameteres, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/develop/examples/core_oculus_rift.c). - -New materials system: now raylib supports standard material properties for 3D models, including diffuse-ambient-specular colors and diffuse-normal-specular textures. Just assign values to standard material and everything is processed internally. - -New lighting system: added support for up to 8 configurable lights and 3 light types: **point**, **directional** and **spot** lights. Just create a light, configure its parameters and raylib manages render internally for every 3d object using standard material. - -Complete gamepad support on Raspberry Pi: Gamepad system has been completely redesigned. Now multiple gamepads can be easily configured and used; gamepad data is read and processed in raw mode in a second thread. - -Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/develop/examples/physics_basic_rigidbody.c). Performance has also been singnificantly improved, now physic objects are managed internally in a second thread. - -Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck. - -Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/develop/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/develop/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms. - -This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/develop/CHANGELOG) file for a more detailed list of changes. - -Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/develop/examples/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/develop/examples/audio_standalone.c) raylib modules as standalone libraries. - -Lots of code changes (+400 commits) and lots of hours of hard work have concluded in this amazing new raylib 1.5. - -notes on raylib 1.6 -------------------- - -On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new version represents another big review of the library and includes some interesting additions. This version conmmemorates raylib 3rd anniversary (raylib 1.0 was published on November 2013) and it is a stepping stone for raylib future. raylib roadmap has been reviewed and redefined to focus on its primary objective: create a simple and easy-to-use library to learn videogames programming. Some of the new features: - -Complete raylib Lua binding. All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality. - -Completely redesigned audio module. Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. FLAC file format support has also been added. In the same line, OpenAL Soft backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more! - -Physac module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by @victorfisac, multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing! - -Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples. - -Improved Gamepad support on Windows and Raspberry Pi with the addition of new functions for custom gamepad configurations but supporting by default PS3 and Xbox-based gamepads. - -Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support. - -Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured Visual Studio C++ 2015 solution with raylib project and C/C++ examples for users that prefer that professional IDE and compiler. - -New examples, new functions, complete code-base review, multiple bugs corrected... this is raylib 1.6. Enjoy making games. - - features -------- @@ -279,3 +115,8 @@ contributing (in some way or another) to make raylib project better. Huge thanks Please, if I forget someone in this list, excuse me and write me an email to remind me to add you! [raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San" + +license +------- + +raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE.md) for further details. -- cgit v1.2.3 From b3b828c8bba76116f353a2010e56a74fd56b388c Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 15 May 2017 18:55:18 +0200 Subject: Update README.md --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 10c4b935..fde1e279 100644 --- a/README.md +++ b/README.md @@ -25,24 +25,22 @@ features * Shaders support, including Model shaders and Postprocessing shaders * Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c) * Audio loading and playing with streaming support and mixing channels (WAV, OGG, FLAC, XM, MOD) + * Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi** and **HTML5** * VR stereo rendering support with configurable HMD device parameters - * Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi**, **HTML5** and **Oculus Rift CV1** * Custom color palette for fancy visuals on raywhite background * Minimal external dependencies (GLFW3, OpenGL, OpenAL) - * Complete binding to LUA + * Complete binding to LUA: [raylib-lua](https://github.com/raysan5/raylib-lua) -raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option by far I found for -multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, ...). +raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option I found for +multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, maintained, ...). raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, [OpenAL Soft](http://kcat.strangesoft.net/openal.html) audio library, in multiple flavours, to accomodate to Android, Raspberry Pi and HTML5. -On Android, raylib uses `native_app_glue module` (provided by Android NDK) and native Android libraries to manage window/context, inputs and activity cycle. +On Android, raylib uses `native_app_glue module` (provided by Android NDK) and native Android libraries to manage window/context, inputs and activity life cycle. On Raspberry Pi, raylib uses Videocore API and EGL for window/context management and raw inputs reading. -On Oculus Rift CV1, raylib uses Oculus PC SDK libraries but only the core C library ([LibOVR](https://github.com/raysan5/raylib/tree/develop/src/external/OculusSDK/LibOVR)); runtime library (LibOVRRT32_1.dll) must be linked at compilation time. - raylib is licensed under a zlib/libpng license. View [LICENSE](https://github.com/raysan5/raylib/blob/master/LICENSE.md). tools requirements -- cgit v1.2.3