Game pixel art nên vẽ trên một màn hình nhỏ cố định (320 x 180) rồi phóng lên, để mọi pixel to bằng nhau ở mọi cỡ cửa sổ.
#include <njin.h>
int main() {
.width = 1280,
.height = 720,
.target_fps = 60,
.resizable = true,
.virtual_size = {320.0f, 180.0f},
.integer_scale = true});
}
context * create(const config &cfg)
Mở cửa sổ và trả về context của engine.
void destroy(context *ctx)
Giải phóng mọi tài nguyên của engine và đóng cửa sổ.
void window_set_bar_color(context &ctx, rgba color)
Màu viền quanh màn hình ảo.
#include <njin.h>
void on_pickup(njin::context &ctx, entt::entity coin, entt::entity player) {
{.done = [coin](njin::context &c) {
}});
{.owner = player});
}
void start_wave(njin::context &ctx) {
}
void pulse(njin::context &ctx, entt::entity button) {
}
int main() {
njin::context *ctx =
njin::create({.title =
"Timers", .width = 640, .height = 360, .target_fps = 60});
(void)on_pickup;
(void)start_wave;
(void)pulse;
}
entt::registry & world(context &ctx)
Trả về registry của EnTT chứa mọi entity và component của game.
scene_handle scene_find(const context &ctx, const char *name)
Tìm scene theo tên.
void scene_fade(context &ctx, scene_handle scene, const scene_transition &transition={})
Chuyển sang scene khác với hiệu ứng mờ dần (fade).
tween_handle tween_tint(context &ctx, entt::entity entity, rgba to, f32 seconds, ease curve=ease::linear, const tween_desc &desc={})
Đổi sprite.tint của entity tới to (cả độ trong suốt).
timer_handle timer_every(context &ctx, f32 interval, std::function< void(context &)> fn, i32 count=-1, const timer_desc &desc={})
Gọi fn mỗi interval giây: sinh quái theo nhịp, hồi máu từ từ.
tween_handle tween_scale(context &ctx, entt::entity entity, f32 to, f32 seconds, ease curve=ease::out_quad, const tween_desc &desc={})
Đổi transform.scale của entity tới to.
timer_handle timer_after(context &ctx, f32 seconds, std::function< void(context &)> fn, const timer_desc &desc={})
Gọi fn một lần sau seconds giây.
tween_handle tween_move(context &ctx, entt::entity entity, vec2 to, f32 seconds, ease curve=ease::out_quad, const tween_desc &desc={})
Dời transform.pos của entity tới to trong seconds giây.
tween_handle tween_value(context &ctx, f32 from, f32 to, f32 seconds, std::function< void(context &, f32)> apply, ease curve=ease::linear, const tween_desc &desc={}, entt::entity owner=entt::null)
Chạy một giá trị từ from tới to và đưa nó cho apply mỗi frame: tween cho bất cứ thứ gì (âm lượng,...
@ out_cubic
Giảm tốc mạnh.
Definition _tween.h:60
@ linear
Đều.
Definition _tween.h:55
@ out_quad
Giảm tốc nhẹ.
Definition _tween.h:57
float f32
Số thực 32 bit.
Definition _types.h:28
Vector 2 chiều. Dùng cho vị trí, kích thước, độ dời.
Definition _types.h:39