Code Monkey home page Code Monkey logo

gamebase's Introduction

About

A lightweight and simple base structure for games, using Heaps framework and Haxe language.

Latest release notes: View changelog.

GitHub Workflow Status GitHub Repo stars

Install

Legacy or master?

Two separate branches exist for GameBase:

  • master: latest GameBase version, actively maintained.
  • legacy: the previous Gamebase version. This one is much more minimalistic but it could be useful if you were looking for a very basic framework for Heaps+Haxe.

The following document will only refer to the master branch.

Getting master

  1. Install Haxe and Hashlink: Step-by-step tutorial
  2. Install required libs by running the following command in the root of the repo: haxe setup.hxml

Compile

From the command line, run either:

  • For DirectX: haxe build.directx.hxml
  • For OpenGL: haxe build.opengl.hxml
  • For Javascript/WebGL: haxe build.js.hxml

The build.dev.hxml is just a shortcut to one of the previous ones, with added -debug flag.

Run the result with either:

  • For DirectX/OpenGL: hl bin\client.hl
  • For Javascript: start run_js.html

Full guide

An in-depth tutorial is available here: Using gamebase to create a game. Please note that this tutorial still refers to the legacy branch, even though the general idea is the same in master branch.

Sample examples

The samples are the recommended places to start for the latest GameBase version (main).

They should give a pretty hands-on understanding of how entities work and how to integrate ldtk to development.

SamplePlayer.hx[SamplePlayer.hx]

SamplePlayer is an Entity with some extra functionalities:

  • user controlled (using gamepad or keyboard)
  • falls with gravity
  • has basic level collisions
  • some squash animations, because it's cheap and they do the job

SampleWorld.hx

A small class that just creates a SamplePlayer instance in the sample level.

Localization

For localization support (ie. translating your game texts), you may also check the following guide.

Questions

Any question? Join the Official Deepnight Games discord.

Cleanup for your own usage

You can safely remove the following files/folders from repo root:

  • .github/
  • LICENSE
  • README.md
  • CHANGELOG.md

gamebase's People

Contributors

deepnight avatar flagrare avatar gcardozo123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gamebase's Issues

Compiling with GCC (Clang)

Hello there,

I've been trying to compile your gameBase project to HL/C using the following commands :

haxe --version
4.0.5
neko -version
2.3.0
hl -version
HL/JIT 1.10.0 (c)2015-2019 Haxe Foundation
  Usage : hl [--debug <port>] [--debug-wait] <file>
haxe base.hxml -hl out/main.c
Converting /private/tmp/gameBase/res/fonts/minecraftiaOutline.fnt
Converting /private/tmp/gameBase/res/fonts/barlow_condensed_medium_regular_9.fnt
Converting /private/tmp/gameBase/res/fonts/barlow_condensed_medium_regular_32.fnt
Converting /private/tmp/gameBase/res/fonts/barlow_condensed_medium_regular_17.fnt
Converting /private/tmp/gameBase/res/fonts/barlow_condensed_medium_regular_11.fnt
Code generated in out/main.c automatic native compilation not yet implemented
/usr/local/lib/haxe/lib/castle/1,6,1/cdb/Lang.hx:200: characters 62-75 : Warning : This typedef is deprecated in favor of haxe.xml.Access
gcc -O3 -o main -std=c11 -I out out/main.c -lhl
Undefined symbols for architecture x86_64:
  "_fmt_compute_mikkt_tangents", referenced from:
      _hl_Mikktspace_compute in main-f2f9f0.o
      _hxd_fmt_fbx_HMDOut_buildTangents in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_deflate_bound", referenced from:
      _haxe_zip_Compress_run in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_deflate_buffer", referenced from:
      _haxe_zip_Compress_execute in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_deflate_init", referenced from:
      _haxe_zip_Compress_run in main-f2f9f0.o
      _haxe_zip_Compress_new in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_digest", referenced from:
      _haxe_crypto_Md5_encode in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_dxt_decode", referenced from:
      _hxd_Pixels_convert in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_inflate_buffer", referenced from:
      _haxe_zip_Uncompress_execute in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_inflate_init", referenced from:
      _haxe_zip_Uncompress_run in main-f2f9f0.o
      _haxe_zip_Uncompress_new in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_jpg_decode", referenced from:
      _hxd_res_Image_decodeJPG in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_png_decode", referenced from:
      _hxd_res_Image_decodePNG in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_zip_end", referenced from:
      _haxe_zip_Compress_run in main-f2f9f0.o
      _haxe_zip_Compress_close in main-f2f9f0.o
      _haxe_zip_Uncompress_run in main-f2f9f0.o
      _haxe_zip_Uncompress_close in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_fmt_zip_flush_mode", referenced from:
      _haxe_zip_Compress_run in main-f2f9f0.o
      _haxe_zip_Compress_setFlushMode in main-f2f9f0.o
      _haxe_zip_Uncompress_run in main-f2f9f0.o
      _haxe_zip_Uncompress_setFlushMode in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_button_new", referenced from:
      _hl_Button_new in main-f2f9f0.o
      _hxd_System_reportError in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_init", referenced from:
      _fun$init in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_loop", referenced from:
      _hxd_System_reportError in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_sentinel_tick", referenced from:
      _hxd_System_start in main-f2f9f0.o
      _hl__UI_Sentinel_Impl__tick in main-f2f9f0.o
      _hxd_System_mainLoop in main-f2f9f0.o
      _hxd_System_runMainLoop in main-f2f9f0.o
      _hxd_System_reportError in main-f2f9f0.o
      _hxd_System_timeoutTick in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
      ...
  "_ui_ui_start_sentinel", referenced from:
      _hl__UI_Sentinel_Impl___new in main-f2f9f0.o
      _fun$init in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_stop_loop", referenced from:
      _hxd_System_reportError__$1 in main-f2f9f0.o
      _hxd_System_reportError__$2 in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_win_destroy", referenced from:
      _hl_Window_destroy in main-f2f9f0.o
      _hxd_System_reportError in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_winlog_new", referenced from:
      _hl_WinLog_new in main-f2f9f0.o
      _hxd_System_reportError in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
  "_ui_ui_winlog_set_text", referenced from:
      _hl_WinLog_setTextContent in main-f2f9f0.o
      _hxd_System_reportError in main-f2f9f0.o
      _hl_functions_ptrs in main-f2f9f0.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How can I fix these unlinked symbols ?

Thanks for your help :)

Use of 3d?

I want something close to Starcraft 2, i.e. 3d game in 2d space. They seem to use the same approach to coordinate system, which you covered in A simple and generic 2D engine, part 1 - Coordinates system (great article btw), also similar to both Northgard and Darksburg.

It seems it fits very well for such usage, even though this gameBase doesn't contain s3d at all (and I haven't found such in advancedBase either). Can you give some insight on what changes your template might need, like Game.hx, Entity.hx, and maybe other classes, to implement this RTS-like experience?

Better CDB builder macro

  • Parse JSON (at least partially) for advanced features
  • Filter out unused values (ie. value2, value3 etc)
  • Use "desc" to create Haxe doc for "values"

Particles v3

  • Add Random helper methods to create random variations on values
    • vary(0.7)
    • random rotations
  • optimize repetitive init sections

How to use LangParser?

I'm trying to figure out how to use the included LangParser. Am I correct that it's purpose is to create .mo files from the *.po files?

It's has been compiled but when i run hl bin/langParse.hl I get the output:

Building sourceTexts file...
[GetText] Parsing source code...
[GetText] Parsing CDBs...
  -> res/data.cdb
[GetText] Saving POT file (res/lang/sourceTexts.pot)...
[GetText] done.
Done.

However, no en.mo file is created. All that is created is a sourceTexts.pot which does not contain the correct translation.

If I change the translation for "Game is ready" to "TEST" in en.po:

#: src/Game.hx:19
msgid "Game is ready."
msgstr "TEST"

The generated sourceTexts.pot looks unchanged:

#: src/Game.hx:32
msgid "Game is ready."
msgstr ""

I also noticed this section in LangParser.hx has an error in vscode:

var data = GetText.doParseGlobal({
	codePath: "src",
	codeIgnore: null,
	cdbFiles: cdbs,
	cdbSpecialId: [],
	potFile: "res/lang/"+name+".pot",
});
Class<dn.data.GetText> has no field doParseGlobal

There is no information about the LangParser in the documentation (tutorial on deepnight or the README)

Failed to load library directx.hdll

Hey โ€” first of all, thanks a lot for sharing this! I was looking forward to try this out (coming from Unity), but I'm unable to start the game (right after cloning).

$ haxe hl.dx.hxml
$ hl bin/client.hl
src/module.c(360) : FATAL ERROR : Failed to load library directx.hdll

I'm on MacOS. Writing an issue here because I have no idea how to debug and googling didn't help. Let me know if I can share anything else about my environment that can help find the problem.

Unable to build advancedBase branch

Is the advancedBase branch considered stable enough to be usable? I can't seem to be able to build it.

I get an issue about

src/Game.hx:116: characters 3-17 : Unknown identifier : timeMultiplier

The standard gameBase is fine though!

Base Screen Scale

Hi @deepnight ,

How to make this gameBase Advance able to scale to LetterBox? Because, it seems it will make all the children objects into the wrong position.

Thank you.

Entity Collider

Hi @deepnight ,

I don't have any idea where to set the collider:
image

My sample player can get through wall. I have also tried the default sample player:
image

If I modified these lines:

// Ceiling collision
if (yr < 0.2 && level.hasCollision(cx, cy - 1)) {
	dy = 0;
	yr = 0.2;
}

into

// Ceiling collision
if (yr < 1.2 && level.hasCollision(cx, cy - 1)) {
	dy = 0;
	yr = 1.2;
}

Everything seems good, but there is a bug, this gif will explain better:
https://imgur.com/a/pu1gBXd

When I press right on the top corner, the player like stuck at the top corner.

Can you help?

Thank you.

Add comments and doc

  • move LEd doc generator to deepnightLibs
  • add comments in Master branch
  • update Advanced branch
  • Publish doc somewhere

Add Entity.isOnScreen(pad)

	public inline function isOnScreen(padding=32) {
		return camera.isOnScreen(centerX, centerY, pad);
	}


	public inline function isOnScreen(levelX:Float, levelY: Float, padding=0.) {
		return levelX>=left-padding && levelX<=right+padding && levelY>=top-padding && levelY<=bottom+padding;
	}

	public inline function isOnScreenCase(cx:Int, cy:Int, padding=32) {
		return cx*Const.GRID>=left-padding && (cx+1)*Const.GRID<=right+padding
			&& cy*Const.GRID>=top-padding && (cy+1)*Const.GRID<=bottom+padding;
	}

Add basic LDtk integration

tl;dr - it's hard for a Haxe/Heaps newb to start with @deepnight 's tutorial on gameBase and end up with a LDtk level in their game.

This ticket could perhaps be split between LDtk and gameBase, but I'll put the bulk of the ticket here.

It's not obvious how to bring LDtk levels into gameBase. While there is an example in ld47 (Footloop), there is enough additional ancillary code in ld47 that it's hard to get going quickly. This is from someone with no Heaps or Haxe experience, so maybe this is obvious to others but just not me. The docs in LDtk explaining the Haxe API show how to load a LDtk level into Haxe objects, but don't explain how one might render it. For example, where are the assets loaded from? Is that handled in the background?

Suggested fixes:

  • Extend LDtk docs to mention gameBase and how to integrate a LDtk level there.
  • Extend gameBase to have a basic LDtk level (maybe by default)? Not just loading the level, but rendering it, maybe with 1 entity converted.
  • Add a short note about things to consider when structuring the level / importer from the perspective of a gameBase user.
  • Add a note somewhere about asset workflow for LDtk in the gameBase/Heaps context. Is there anything to know?

Thank you for releasing the wonderful LDtk tool!

No player?

Hi, I noticed you updated the advanced branch with an ldtk map and I wanted to check how it works.
I've no issues compiling with haxe and running with hashlink, but I noticed there's no player entity in the demo.

Scaling ui.Console with offset

Hi, I have noticed that after scaling the ui.Console by 2, the command input does not align the bottom. Is there any work around on it?

How to use Hud.hx ??

I have a question, where i need to put text as header display in his GameBase ??, it has parameters such as the s2d variable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.