Add files to the repo
21
LICENSE.txt
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-2019 iProgramInCpp
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
194
Makefile
Normal file
@ -0,0 +1,194 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
.SECONDARY:
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/base_rules
|
||||
|
||||
PORTLIBS := $(PORTLIBS_PATH)/nds $(PORTLIBS_PATH)/armv5te
|
||||
|
||||
LIBNDS := $(DEVKITPRO)/libnds
|
||||
|
||||
ifeq ($(strip $(GAME_TITLE)),)
|
||||
GAME_TITLE := game
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(GAME_SUBTITLE1)),)
|
||||
GAME_SUBTITLE1 := test
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(GAME_SUBTITLE2)),)
|
||||
GAME_SUBTITLE2 := Made by iProgramInCpp
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(GAME_ICON)),)
|
||||
GAME_ICON := $(DEVKITPRO)/libnds/icon.bmp
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(NITRO_FILES)),)
|
||||
_ADDFILES := -d $(NITRO_FILES)
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.nds: %.arm9
|
||||
$(SILENTCMD)ndstool -c $@ -9 $< -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" $(_ADDFILES)
|
||||
@echo built ... $(notdir $@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.nds: %.elf
|
||||
ndstool -c $@ -9 $< -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" $(_ADDFILES) -h 0x200
|
||||
$(SILENTMSG) built ... $(notdir $@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.arm9: %.elf
|
||||
$(SILENTCMD)$(OBJCOPY) -O binary $< $@
|
||||
$(SILENTMSG) built ... $(notdir $@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.arm7: %.elf
|
||||
$(SILENTCMD)$(OBJCOPY) -O binary $< $@
|
||||
$(SILENTMSG) built ... $(notdir $@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.elf:
|
||||
$(SILENTMSG) linking $(notdir $@)
|
||||
$(SILENTCMD)$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(shell basename $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA :=
|
||||
INCLUDES := include
|
||||
GRAPHICS := data
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -mthumb -mthumb-interwork
|
||||
|
||||
CFLAGS := -g -Wall -O2\
|
||||
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
|
||||
-ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM9
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++14
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lfat -lnds9
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(LIBNDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(PNGFILES:.png=.o) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
.PHONY: $(BUILD) clean
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).ds.gba
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).nds : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.s %.h : %.png %.grit
|
||||
#---------------------------------------------------------------------------------
|
||||
grit $< -fts -o$*
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
18
README.md
@ -1,2 +1,16 @@
|
||||
# DSPlatformMaker
|
||||
Platformer game maker for the Nintendo DS.
|
||||
# DSGameEngine
|
||||
A DS game engine based off libnds with frame buffer capabilities for the top screen.
|
||||
|
||||
It includes basic image drawing functions with transparency and flipping, and basic rectangle drawing.
|
||||
|
||||
The graphics work is all done in software, only that the CPU will copy the framebuffer data to the GPU of the Nintendo DS.
|
||||
|
||||
It's quite inefficient, but who needs backgrounds and sprites when you can have this?
|
||||
|
||||
|
||||
This repo will also have examples of programs written based off it.
|
||||
|
||||
The platform game contains sprites from New Super Mario Bros. for the Nintendo DS. I won't provide them here for legal reasons.
|
||||
The 3D engine doesn't contain any other things.
|
||||
|
||||
You need devkitPro (namely devkitARM) to build.
|
||||
|
8
build.bat
Normal file
@ -0,0 +1,8 @@
|
||||
@echo off
|
||||
cd C:\Users\iProgramInCpp\Desktop\game
|
||||
rem set DEVKITARM=C:\devkitPro\devkitARM
|
||||
rem set DEVKITPRO=C:\devkitPro
|
||||
rem set PATH=C:\devkitPro\msys2
|
||||
rem msys2_shell.bat C:\Users\iProgramInCpp\Desktop\game\build.sh
|
||||
make
|
||||
pause
|
5
build.sh
Normal file
@ -0,0 +1,5 @@
|
||||
cd /home/iProgramInCpp/Desktop/game
|
||||
export DEVKITPRO=C:/Devkitpro/
|
||||
export DEVKITARM=C:/Devkitpro/Devkitarm
|
||||
make
|
||||
read -p "Press [Enter] key to start backup..."
|
7
clean.bat
Normal file
@ -0,0 +1,7 @@
|
||||
@echo off
|
||||
rem cd C:\Users\Myria\Desktop\DSGAME
|
||||
rem set DEVKITARM=C:\devkitPro\devkitARM
|
||||
rem set DEVKITPRO=C:\devkitPro
|
||||
rem set PATH=C:\devkitPro\msys2
|
||||
rem msys2_shell.bat C:\Users\Myria\Desktop\DSGAME\clean.sh
|
||||
make clean
|
BIN
data/bmpfont.png
Normal file
After Width: | Height: | Size: 941 B |
BIN
data/character.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
data/clapperboard.png
Normal file
After Width: | Height: | Size: 362 B |
BIN
data/copy_mode.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
data/dialog_bg.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
data/dialogbtn.png
Normal file
After Width: | Height: | Size: 567 B |
BIN
data/erase.png
Normal file
After Width: | Height: | Size: 699 B |
BIN
data/erase_mode.png
Normal file
After Width: | Height: | Size: 259 B |
BIN
data/item.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
data/itemsel.png
Normal file
After Width: | Height: | Size: 230 B |
BIN
data/logo.png
Normal file
After Width: | Height: | Size: 957 B |
BIN
data/lr_arrows.png
Normal file
After Width: | Height: | Size: 274 B |
BIN
data/reset.png
Normal file
After Width: | Height: | Size: 754 B |
BIN
data/tiles.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
data/undo.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
data/zombie.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
232
source/Enemy.cpp
Normal file
@ -0,0 +1,232 @@
|
||||
#include "Enemy.hpp"
|
||||
|
||||
|
||||
#include "zombie.h"
|
||||
|
||||
glImage* mushroomImage;
|
||||
glImage zombieImage[8];
|
||||
short zombieBmp[128*16];
|
||||
int zombSpriteID;
|
||||
|
||||
Enemy::Enemy() {
|
||||
|
||||
}
|
||||
Enemy::~Enemy() {
|
||||
|
||||
}
|
||||
|
||||
void Enemy::Update (float fElapsedTime) {
|
||||
if (this->posY > nLevelHeight) return;
|
||||
if (this->posX > nLevelWidth) return;
|
||||
if (this->posX < 0) return;
|
||||
if (this->markForRemoval) return;
|
||||
switch (type) {
|
||||
case Enemy_Mushroom:
|
||||
case Enemy_LifeUp: {
|
||||
if (mushroom.risingTimer > 0.0f) {
|
||||
if ((BlockBumpedX != (int)homeX || BlockBumpedY != (int)homeY)) {
|
||||
mushroom.risingTimer -= fElapsedTime;
|
||||
posY -= fElapsedTime;
|
||||
if (mushroom.risingTimer <= 0.0f) {
|
||||
mushroom.risingTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
velX = 5;
|
||||
} else {
|
||||
// gravity
|
||||
velY += 20.0f * fElapsedTime;
|
||||
isOnGround = false;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
float newX = posX + fElapsedTime * velX * .2f;
|
||||
float newY = posY + fElapsedTime * velY * .2f;
|
||||
|
||||
if (velX < 0) {
|
||||
if (IsSolid(GetTile(newX + 0.0f, posY + 0.0f), DIR_LEFT) ||
|
||||
IsSolid(GetTile(newX + 0.0f, posY + 0.9f), DIR_LEFT)) {
|
||||
velX = -velX;
|
||||
newX = (int)newX + 1;
|
||||
}
|
||||
} else if (velX > 0) {
|
||||
if (IsSolid(GetTile(newX + 1.0f, posY + 0.0f), DIR_RIGHT) ||
|
||||
IsSolid(GetTile(newX + 1.0f, posY + 0.9f), DIR_RIGHT)) {
|
||||
velX = -velX;
|
||||
newX = (int)newX;
|
||||
}
|
||||
}
|
||||
if (velY < 0) {
|
||||
// no triggering blocks
|
||||
if (IsSolid(GetTile(newX + 0.0f, newY), DIR_UP) ||
|
||||
IsSolid(GetTile(newX + 0.9f, newY), DIR_UP)) {
|
||||
velY = 0;
|
||||
newY = (int)newY + 1;
|
||||
}
|
||||
}
|
||||
if (velY > 0) {
|
||||
if (IsSolid(GetTile(newX + 0.0f, newY + 1.0f), DIR_DOWN) ||
|
||||
IsSolid(GetTile(newX + 0.9f, newY + 1.0f), DIR_DOWN)) {
|
||||
velY = 0;
|
||||
newY = (int)newY;
|
||||
}
|
||||
}
|
||||
posX = newX; posY = newY;
|
||||
}
|
||||
if (isOnGround) {
|
||||
if (velX == 0) velX = 5;
|
||||
}
|
||||
Rectangle ri = { (int)(posX * 100), (int)(posY * 100), 100, 100};
|
||||
Rectangle rp = { (int)(fPlayerPosX * 100 + 20), (int)(fPlayerPosY * 100), 100, 80 };
|
||||
if (RectangleIntersect(ri, rp)) {
|
||||
if (type == Enemy_LifeUp)
|
||||
IncreaseMaxHP();
|
||||
else
|
||||
HealPlayer();
|
||||
// have to be overlapping with the mushroom quite a bit
|
||||
this->markForRemoval = true;
|
||||
score += 1000; // todo: increase lives
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Enemy_Flower:
|
||||
case Enemy_Time: {
|
||||
if (mushroom.risingTimer > 0.0f) {
|
||||
if ((BlockBumpedX != (int)homeX || BlockBumpedY != (int)homeY)) {
|
||||
mushroom.risingTimer -= fElapsedTime;
|
||||
posY -= fElapsedTime;
|
||||
if (mushroom.risingTimer <= 0.0f) {
|
||||
mushroom.risingTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// gravity
|
||||
velY += 20.0f * fElapsedTime;
|
||||
isOnGround = false;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
float newX = posX + fElapsedTime * velX * .2f;
|
||||
float newY = posY + fElapsedTime * velY * .2f;
|
||||
|
||||
if (velX < 0) {
|
||||
if (IsSolid(GetTile(newX + 0.0f, posY + 0.0f), DIR_LEFT) ||
|
||||
IsSolid(GetTile(newX + 0.0f, posY + 0.9f), DIR_LEFT)) {
|
||||
velX = -velX;
|
||||
newX = (int)newX + 1;
|
||||
}
|
||||
} else if (velX > 0) {
|
||||
if (IsSolid(GetTile(newX + 1.0f, posY + 0.0f), DIR_RIGHT) ||
|
||||
IsSolid(GetTile(newX + 1.0f, posY + 0.9f), DIR_RIGHT)) {
|
||||
velX = -velX;
|
||||
newX = (int)newX;
|
||||
}
|
||||
}
|
||||
if (velY < 0) {
|
||||
// no triggering blocks
|
||||
if (IsSolid(GetTile(newX + 0.0f, newY), DIR_UP) ||
|
||||
IsSolid(GetTile(newX + 0.9f, newY), DIR_UP)) {
|
||||
velY = 0;
|
||||
newY = (int)newY + 1;
|
||||
}
|
||||
}
|
||||
if (velY > 0) {
|
||||
if (IsSolid(GetTile(newX + 0.0f, newY + 1.0f), DIR_DOWN) ||
|
||||
IsSolid(GetTile(newX + 0.9f, newY + 1.0f), DIR_DOWN)) {
|
||||
velY = 0;
|
||||
newY = (int)newY;
|
||||
}
|
||||
}
|
||||
posX = newX; posY = newY;
|
||||
}
|
||||
Rectangle ri = { (int)(posX * 100), (int)(posY * 100), 100, 100};
|
||||
// offset the player rectangle a bit to avoid collecting while inside the box
|
||||
Rectangle rp = { (int)(fPlayerPosX * 100 + 20), (int)(fPlayerPosY * 100), 100, 80 };
|
||||
if (RectangleIntersect(ri, rp)) {
|
||||
// have to be overlapping with the mushroom quite a bit
|
||||
this->markForRemoval = true;
|
||||
score += 1000;
|
||||
if (type == Enemy_Time) {
|
||||
inGameTime += 10.f;
|
||||
} else {
|
||||
DamagePlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy::CommonDrawAtOffset(glImage* img, float pX, float pY, float oX, float oY, int flipMode) {
|
||||
int sx = (posX - oX) * 16;
|
||||
int sy = (posY - oY) * 16 + 1;
|
||||
//glSprite(sx, sy, flipMode, img);
|
||||
DrawImage(img, img->width, img->height, sx, sy);
|
||||
}
|
||||
|
||||
void Enemy::Draw (float fOffsetX, float fOffsetY) {
|
||||
glImage* toDraw = nullptr;
|
||||
int flipMode = 0;
|
||||
switch (type) {
|
||||
case Enemy_Mushroom: {
|
||||
flipMode = this->mushroom.movingLeft ? GL_FLIP_H : 0;
|
||||
// This should move the mushroom to behind the blocks during its rise anim
|
||||
if ((BlockBumpedX != (int)homeX || BlockBumpedY != (int)homeY)) {
|
||||
CommonDrawAtOffset(&tilesImage[33], posX, posY, fOffsetX, fOffsetY, flipMode);
|
||||
if (homeX != 0 || homeY != 0) {
|
||||
int mx = (homeX - fOffsetX) * 16;
|
||||
int my = (homeY - fOffsetY) * 16;
|
||||
DrawTile('U',mx,my,'.');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Enemy_Flower: {
|
||||
flipMode = this->mushroom.movingLeft ? GL_FLIP_H : 0;
|
||||
// This should move the mushroom to behind the blocks during its rise anim
|
||||
if ((BlockBumpedX != (int)homeX || BlockBumpedY != (int)homeY)) {
|
||||
CommonDrawAtOffset(&tilesImage[36], posX, posY, fOffsetX, fOffsetY, flipMode);
|
||||
if (homeX != 0 || homeY != 0) {
|
||||
int mx = (homeX - fOffsetX) * 16;
|
||||
int my = (homeY - fOffsetY) * 16;
|
||||
DrawTile('U',mx,my,'.');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Enemy_Time: {
|
||||
flipMode = this->mushroom.movingLeft ? GL_FLIP_H : 0;
|
||||
// This should move the mushroom to behind the blocks during its rise anim
|
||||
if ((BlockBumpedX != (int)homeX || BlockBumpedY != (int)homeY)) {
|
||||
CommonDrawAtOffset(&tilesImage[37], posX, posY, fOffsetX, fOffsetY, flipMode);
|
||||
if (homeX != 0 || homeY != 0) {
|
||||
int mx = (homeX - fOffsetX) * 16;
|
||||
int my = (homeY - fOffsetY) * 16;
|
||||
DrawTile('U',mx,my,'.');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Enemy_LifeUp: {
|
||||
flipMode = this->mushroom.movingLeft ? GL_FLIP_H : 0;
|
||||
// This should move the mushroom to behind the blocks during its rise anim
|
||||
if ((BlockBumpedX != (int)homeX || BlockBumpedY != (int)homeY)) {
|
||||
CommonDrawAtOffset(&tilesImage[38], posX, posY, fOffsetX, fOffsetY, flipMode);
|
||||
if (homeX != 0 || homeY != 0) {
|
||||
int mx = (homeX - fOffsetX) * 16;
|
||||
int my = (homeY - fOffsetY) * 16;
|
||||
DrawTile('U',mx,my,'.');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Enemy_Zombie:
|
||||
flipMode = this->zombie.movingLeft ? GL_FLIP_H : 0;
|
||||
toDraw = &zombieImage[1];
|
||||
CommonDrawAtOffset(toDraw, posX, posY, fOffsetX, fOffsetY, flipMode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy::CommonLoad() {
|
||||
mushroomImage = &tilesImage[33];
|
||||
decompress(zombieBitmap, zombieBmp, LZ77);
|
||||
zombSpriteID = glLoadTileSet(zombieImage,16,16,128,16, GL_RGBA, TEXTURE_SIZE_128, TEXTURE_SIZE_16, GL_TEXTURE_WRAP_S|GL_TEXTURE_WRAP_T|TEXGEN_OFF|GL_TEXTURE_COLOR0_TRANSPARENT, 0, NULL, (u8*)zombieBmp);
|
||||
}
|
31
source/Enemy.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "TestGame.hpp"
|
||||
|
||||
#define Enemy_Mushroom 1
|
||||
#define Enemy_Zombie 2
|
||||
#define Enemy_Flower 3
|
||||
#define Enemy_Time 4
|
||||
#define Enemy_LifeUp 5
|
||||
|
||||
class Enemy {
|
||||
public:
|
||||
int type;
|
||||
float posX = 0, posY = 0;
|
||||
float homeX = 0, homeY = 0;
|
||||
float velX = 0, velY = 0;
|
||||
bool isOnGround = false;
|
||||
bool markForRemoval = false;
|
||||
union {
|
||||
struct {
|
||||
bool movingLeft = false;
|
||||
float risingTimer = 0.0f;
|
||||
} mushroom;
|
||||
struct {
|
||||
bool movingLeft = false;
|
||||
} zombie;
|
||||
};
|
||||
Enemy(); ~Enemy();
|
||||
void CommonDrawAtOffset(glImage* img, float pX, float pY, float oX, float oY, int flipMode);
|
||||
void Update(float deltaTime);
|
||||
void Draw(float fOffsetX, float fOffsetY);
|
||||
static void CommonLoad();
|
||||
};
|
674
source/Engine.h
Normal file
@ -0,0 +1,674 @@
|
||||
#ifndef DS_GAME_ENGINE_INCL
|
||||
#define DS_GAME_ENGINE_INCL
|
||||
|
||||
#include "EngineDec.h"
|
||||
#include "Map.h"
|
||||
#include <gl2d.h>
|
||||
|
||||
/*
|
||||
int round(float f){
|
||||
float decpt = f - (int)f;
|
||||
if(decpt < 0.5f){
|
||||
return (int)f;
|
||||
}else{
|
||||
return (int)f+1;
|
||||
}
|
||||
}*/
|
||||
|
||||
short screenbuffer_maindisplay[49152];
|
||||
short screen_width = 256;
|
||||
short screen_height = 192;
|
||||
|
||||
uint32_t input_keys = 0;
|
||||
uint32_t input_keysUp = 0;
|
||||
uint32_t input_keysDown = 0;
|
||||
uint32_t input_keysHeld = 0;
|
||||
|
||||
uint8_t GraphScreen;
|
||||
|
||||
touchPosition touch;
|
||||
touchPosition prevTouch;
|
||||
PrintConsole bottomScreen;
|
||||
|
||||
#define PlotPixel2(x,y,c) screenbuffer_maindisplay[(y)*256+(x)]=c
|
||||
|
||||
bool GetKeyState(uint32_t button){
|
||||
uint32_t s = input_keys & button;
|
||||
return s;
|
||||
}
|
||||
bool GetKeyDownState(uint32_t button){
|
||||
uint32_t s = input_keysDown & button;
|
||||
return s;
|
||||
}
|
||||
bool GetKeyUpState(uint32_t button){
|
||||
uint32_t s = input_keysUp & button;
|
||||
return s;
|
||||
}
|
||||
bool GetKeyHeldState(uint32_t button){
|
||||
uint32_t s = input_keysHeld & button;
|
||||
return s;
|
||||
}
|
||||
/*
|
||||
void PushFrame(){
|
||||
if(GraphScreen == SCREEN_BOTTOM)
|
||||
{
|
||||
dmaCopy(&screenbuffer_maindisplay, BG_GFX_SUB, 49152*2);
|
||||
}
|
||||
else
|
||||
{
|
||||
dmaCopy(&screenbuffer_maindisplay, BG_GFX, 49152*2);
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchScreenBottom()
|
||||
{
|
||||
GraphScreen = SCREEN_TOP;
|
||||
// Console is on bottom screen
|
||||
videoSetMode(MODE_5_2D);
|
||||
//videoSetModeSub(MODE_0_2D);
|
||||
|
||||
vramSetBankA(VRAM_A_MAIN_BG);
|
||||
//vramSetBankC(VRAM_C_SUB_BG);
|
||||
|
||||
bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 0,0);
|
||||
|
||||
//consoleInit(&topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
|
||||
consoleInit(&bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
ClearScreen(0x0000);
|
||||
PushFrame();
|
||||
}
|
||||
void SwitchScreenTop()
|
||||
{
|
||||
GraphScreen = SCREEN_BOTTOM;
|
||||
// Console is on top screen
|
||||
//videoSetModeSub(MODE_5_2D);
|
||||
videoSetMode(MODE_0_2D);
|
||||
|
||||
vramSetBankA(VRAM_A_MAIN_BG);
|
||||
//vramSetBankC(VRAM_C_SUB_BG);
|
||||
|
||||
//bgInitSub(2, BgType_Bmp16, BgSize_B16_256x256, 0,0);
|
||||
|
||||
//consoleInit(&topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
|
||||
consoleInit(&bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
|
||||
ClearScreen(0x0000);
|
||||
PushFrame();
|
||||
}
|
||||
|
||||
void PlotPixel (int x, int y, short colour)
|
||||
{
|
||||
if((x) >= 0 && (x) < 256 && (y) >= 0 && (y) < 192){
|
||||
screenbuffer_maindisplay[y*screen_width+x] = colour;
|
||||
}
|
||||
}
|
||||
|
||||
void ClearScreen(short colour){
|
||||
for(int x = 0; x < 49152; x+=1){
|
||||
//PlotPixel(x % 256, x / 256, colour);
|
||||
screenbuffer_maindisplay[x]=colour;
|
||||
}
|
||||
}
|
||||
|
||||
void FillRectangle(short colour, int dx, int dy, int w, int h){
|
||||
for(int y = 0; y < h; y++){
|
||||
for(int x = 0; x < w; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
PlotPixel2(x+dx, dy+y, colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void FillRectangleLerp(short colour1, short colour2, int dx, int dy, int w, int h){
|
||||
for(int y = 0; y < h; y++){
|
||||
for(int x = 0; x < w; x++){
|
||||
short colour = color_lerp(colour1, colour2, x * 255 / w);
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
PlotPixel2(x+dx, dy+y, colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void DrawRectangle(short colour, int dx, int dy, int w, int h){
|
||||
int x = 0;
|
||||
for(x = 0; x < w; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256){
|
||||
PlotPixel2((x + dx), dy, colour);
|
||||
}
|
||||
}
|
||||
for(x = 0; x < w; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256){
|
||||
PlotPixel2((x + dx), (dy - 1 + h), colour);
|
||||
}
|
||||
}
|
||||
for(x = 0; x < h; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256){
|
||||
PlotPixel2((dx), (x + dy), colour);
|
||||
}
|
||||
}
|
||||
for(x = 0; x < h; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256){
|
||||
PlotPixel2((w + dx - 1), (x + dy), colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawLine (int x1, int y1, int x2, int y2, short col){
|
||||
int x, y, dx, dy, dx1, dy1, px, py, xe, ye, i;
|
||||
dx = x2 - x1; dy = y2 - y1;
|
||||
dx1 = abs(dx); dy1 = abs(dy);
|
||||
px = 2 * dy1 - dx1; py = 2 * dx1 - dy1;
|
||||
if (dy1 <= dx1)
|
||||
{
|
||||
if (dx >= 0)
|
||||
{ x = x1; y = y1; xe = x2; }
|
||||
else
|
||||
{ x = x2; y = y2; xe = x1;}
|
||||
|
||||
PlotPixel2(x, y, col);
|
||||
|
||||
for (i = 0; x<xe; i++)
|
||||
{
|
||||
x = x + 1;
|
||||
if (px<0)
|
||||
px = px + 2 * dy1;
|
||||
else
|
||||
{
|
||||
if ((dx<0 && dy<0) || (dx>0 && dy>0)) y = y + 1; else y = y - 1;
|
||||
px = px + 2 * (dy1 - dx1);
|
||||
}
|
||||
PlotPixel2(x, y, col);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dy >= 0)
|
||||
{ x = x1; y = y1; ye = y2; }
|
||||
else
|
||||
{ x = x2; y = y2; ye = y1; }
|
||||
|
||||
PlotPixel2(x, y, col);
|
||||
|
||||
for (i = 0; y<ye; i++)
|
||||
{
|
||||
y = y + 1;
|
||||
if (py <= 0)
|
||||
py = py + 2 * dx1;
|
||||
else
|
||||
{
|
||||
if ((dx<0 && dy<0) || (dx>0 && dy>0)) x = x + 1; else x = x - 1;
|
||||
py = py + 2 * (dx1 - dy1);
|
||||
}
|
||||
PlotPixel2(x, y, col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTriangle (int x1, int y1, int x2, int y2, int x3, int y3, short colour){
|
||||
DrawLine (x1, y1, x2, y2, colour);
|
||||
DrawLine (x1, y1, x3, y3, colour);
|
||||
DrawLine (x3, y3, x2, y2, colour);
|
||||
}
|
||||
|
||||
void FillTriangle (int x1, int y1, int x2, int y2, int x3, int y3, short col){
|
||||
/ * Ripped from OneLoneCoder/ConsoleGameEngine * /
|
||||
int x, y, dx, dy, dx1, dy1, px, py, xe, ye, i;
|
||||
dx = x2 - x1; dy = y2 - y1;
|
||||
dx1 = abs(dx); dy1 = abs(dy);
|
||||
px = 2 * dy1 - dx1; py = 2 * dx1 - dy1;
|
||||
if (dy1 <= dx1)
|
||||
{
|
||||
if (dx >= 0)
|
||||
{ x = x1; y = y1; xe = x2; }
|
||||
else
|
||||
{ x = x2; y = y2; xe = x1;}
|
||||
|
||||
PlotPixel2(x, y, col);
|
||||
DrawLine(x, y, x3, y3, col);
|
||||
|
||||
for (i = 0; x<xe; i++)
|
||||
{
|
||||
x = x + 1;
|
||||
if (px<0)
|
||||
px = px + 2 * dy1;
|
||||
else
|
||||
{
|
||||
if ((dx<0 && dy<0) || (dx>0 && dy>0)) y = y + 1; else y = y - 1;
|
||||
px = px + 2 * (dy1 - dx1);
|
||||
}
|
||||
PlotPixel2(x, y, col);
|
||||
DrawLine(x, y, x3, y3, col);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dy >= 0)
|
||||
{ x = x1; y = y1; ye = y2; }
|
||||
else
|
||||
{ x = x2; y = y2; ye = y1; }
|
||||
|
||||
PlotPixel2(x, y, col);
|
||||
DrawLine(x, y, x3, y3, col);
|
||||
|
||||
for (i = 0; y<ye; i++)
|
||||
{
|
||||
y = y + 1;
|
||||
if (py <= 0)
|
||||
py = py + 2 * dx1;
|
||||
else
|
||||
{
|
||||
if ((dx<0 && dy<0) || (dx>0 && dy>0)) x = x + 1; else x = x - 1;
|
||||
py = py + 2 * (dx1 - dy1);
|
||||
}
|
||||
PlotPixel2(x, y, col);
|
||||
DrawLine(x, y, x3, y3, col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawImageSizable(short* image, int w, int h, int dx, int dy, int dw, int dh){
|
||||
/ *float pixel_width = dw / w;
|
||||
float pixel_height= dh / h;
|
||||
|
||||
for(int y = 0; y < dh; y++){
|
||||
for(int x = 0; x < dw; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
int src_y = round(y * pixel_height);
|
||||
int src_x = round(x * pixel_width);
|
||||
screenbuffer_maindisplay[(dy+y)*screen_width+(x+dx)] = image[(src_y*w+src_x)];
|
||||
}
|
||||
}
|
||||
}* /
|
||||
|
||||
int w2 = dw, w1 = w, h2 = dh, h1 = h;
|
||||
|
||||
// EDIT: added +1 to account for an early rounding problem
|
||||
int x_ratio = (int)((w1<<16)/w2) +1;
|
||||
int y_ratio = (int)((h1<<16)/h2) +1;
|
||||
|
||||
int x2, y2 ;
|
||||
for (int i=0;i<h2;i++) {
|
||||
for (int j=0;j<w2;j++) {
|
||||
x2 = ((j*x_ratio)>>16) ;
|
||||
y2 = ((i*y_ratio)>>16) ;
|
||||
if((j+dx) >= 0 && (j+dx) < 256 && (i+dy) >= 0 && (i+dy) < 192){
|
||||
PlotPixel2(j+dx,i+dy,image[(y2*w1)+x2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawImage(short* image, int w, int h, int dx, int dy){
|
||||
for(int y = 0; y < h; y++){
|
||||
for(int x = 0; x < w; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
if(image[y*w+x] == -993){}else{
|
||||
PlotPixel2(x+dx,y+dy,image[y*w+x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawImageCrop(short* image, int w, int h, int dx, int dy, int sx, int sy, int dw, int dh){
|
||||
for(int y = 0; y < dh; y++){
|
||||
for(int x = 0; x < dw; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
if(image[(sy+y)*w+(sx+x)] == -993){}else{
|
||||
PlotPixel2(x+dx,y+dy,image[(sy+y)*w+(sx+x)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawImageCropFlipH(short* image, int w, int h, int dx, int dy, int sx, int sy, int dw, int dh){
|
||||
for(int y = 0; y < dh; y++){
|
||||
for(int x = 0; x < dw; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
if(image[(sy+y)*w+(sx+dw-1-x)] == -993){}else{
|
||||
PlotPixel2(x+dx,y+dy,image[(sy+y)*w+(sx+dw-1-x)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawImageFlippedV(short* image, int w, int h, int dx, int dy){
|
||||
for(int y = 0; y < h; y++){
|
||||
for(int x = 0; x < w; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
if(image[(h-y-1)*w+x] == -993){}else{
|
||||
PlotPixel2(x+dx,y+dy,image[(h-y-1)*w+x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void DrawImageFlippedHV(short* image, int w, int h, int dx, int dy){
|
||||
for(int y = 0; y < h; y++){
|
||||
for(int x = 0; x < w; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
if(image[(h-y)*w+(w-x-1)] == -993){}else{
|
||||
PlotPixel2(x+dx,y+dy,image[(h-y)*w+(w-x-1)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void DrawImageFlippedH(short* image, int w, int h, int dx, int dy){
|
||||
for(int y = 0; y < h; y++){
|
||||
for(int x = 0; x < w; x++){
|
||||
if((x+dx) >= 0 && (x+dx) < 256 && (y+dy) >= 0 && (y+dy) < 192){
|
||||
if(image[y*w+(w-x-1)] == -993){}else{
|
||||
PlotPixel2(x+dx,y+dy,image[y*w+(w-x-1)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void PushFrame() {
|
||||
glFlush(0);
|
||||
}
|
||||
|
||||
void PlotPixel(int x, int y, short color) {
|
||||
// todo
|
||||
glPutPixel(x, y, 0xffff);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
u8 r,g,b,a;
|
||||
};
|
||||
u32 c;
|
||||
};
|
||||
} color_t;
|
||||
|
||||
inline float MapX(int x) {
|
||||
double f = (double)x / 128.0 * .935;
|
||||
f -= .935;
|
||||
return (float)f;
|
||||
}
|
||||
inline float MapY(int y) {
|
||||
double f = (191 - y) / 96.0 * .7;
|
||||
f -= .7;
|
||||
return (float)f;
|
||||
}
|
||||
color_t MakeColort(short color) {
|
||||
color_t c;
|
||||
c.r = (color & 0x1f) * 8;
|
||||
c.g = ((color >> 5) & 0x3f) >> 2;
|
||||
c.b = ((color >> 11) & 0x1f);
|
||||
c.a = ((color & 0x8000) ? 31 : 0) << 3;
|
||||
return c;
|
||||
}
|
||||
|
||||
void ClearScreen(short color) {
|
||||
color_t c = MakeColort(color);
|
||||
glClearColor(c.r, c.g, c.b, c.a);
|
||||
}
|
||||
#define fv floattov16
|
||||
void FillRectangle(short color, int dx, int dy, int w, int h) {
|
||||
glBoxFilled(dx,dy,dx+w,dy+h,color);
|
||||
}
|
||||
void FillRectangleLerp(short co1, short co2, int dx, int dy, int w, int h)
|
||||
{
|
||||
glBoxFilledGradient(dx,dy,dx+w,dy+h,co1,co1,co2,co2);
|
||||
}
|
||||
void DrawRectangle(short color, int dx, int dy, int w, int h) {
|
||||
glBox(dx,dy,dx+w,dy+h,color);
|
||||
}
|
||||
void DrawLine(int x1, int y1, int x2, int y2, short col) {
|
||||
glLine(x1,y1,x2,y2,MakeColort(col).c);
|
||||
}
|
||||
int GetGLTexSizeEnum(int w) {
|
||||
/**/ if (w <= 8) return TEXTURE_SIZE_8;
|
||||
else if (w <= 16) return TEXTURE_SIZE_16;
|
||||
else if (w <= 32) return TEXTURE_SIZE_32;
|
||||
else if (w <= 64) return TEXTURE_SIZE_64;
|
||||
else if (w <= 128) return TEXTURE_SIZE_128;
|
||||
else if (w <= 256) return TEXTURE_SIZE_256;
|
||||
else if (w <= 512) return TEXTURE_SIZE_512;
|
||||
else if (w <= 1024) return TEXTURE_SIZE_1024;
|
||||
return TEXTURE_SIZE_1024;
|
||||
}
|
||||
int imageIDsReserved[TEXTURE_COUNT];
|
||||
int nextImageIdx;
|
||||
int LoadImageVRAM(short* image, int w, int h) {
|
||||
bool b = glTexImage2D(imageIDsReserved[nextImageIdx], 0, GL_RGBA, GetGLTexSizeEnum(w),GetGLTexSizeEnum(h), 0, 0, image);
|
||||
LogMsg("Loading image with size %dx%d (it got id %d) was %s", w, h,imageIDsReserved[nextImageIdx], b ? "successful":"unsuccessful");
|
||||
return imageIDsReserved[nextImageIdx++];
|
||||
}
|
||||
void FillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short colour) {
|
||||
glTriangleFilled(x1,y1,x2,y2,x3,y3,colour);
|
||||
}
|
||||
void DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short colour) {
|
||||
glTriangle(x1,y1,x2,y2,x3,y3,colour);
|
||||
}
|
||||
void DrawImageSizable(glImage* image, int w, int h, int dx, int dy, int dw, int dh){}
|
||||
void SwitchScreenTop(){}
|
||||
void SwitchScreenBottom(){}
|
||||
|
||||
static v16 g_depth;
|
||||
static inline void gxVertex3i_re(v16 x, v16 y, v16 z)
|
||||
{
|
||||
GFX_VERTEX16 = (y << 16) | (x & 0xFFFF);
|
||||
GFX_VERTEX16 = ((uint32)(uint16)z);
|
||||
}
|
||||
static inline void gxTexcoord2i_re(t16 u, t16 v)
|
||||
{
|
||||
GFX_TEX_COORD = (v << 20) | ( (u << 4) & 0xFFFF );
|
||||
}
|
||||
static inline void gxVertex2i_re(v16 x, v16 y)
|
||||
{
|
||||
GFX_VERTEX_XY = (y << 16) | (x & 0xFFFF);
|
||||
}
|
||||
void DrawImageColored(glImage* spr, int w, int h, int dx, int dy, int flipmode, u16 color) {
|
||||
// Cannot use glSprite, gotta recreate it
|
||||
/*
|
||||
int x1 = dx;
|
||||
int y1 = dy;
|
||||
int x2 = dx + spr->width;
|
||||
int y2 = dy + spr->height;
|
||||
|
||||
int u1 = spr->u_off + (( flipmode & GL_FLIP_H ) ? spr->width-1 : 0);
|
||||
int u2 = spr->u_off + (( flipmode & GL_FLIP_H ) ? 0 : spr->width);
|
||||
int v1 = spr->v_off + (( flipmode & GL_FLIP_V ) ? spr->height-1 : 0);
|
||||
int v2 = spr->v_off + (( flipmode & GL_FLIP_V ) ? 0 : spr->height);
|
||||
|
||||
|
||||
|
||||
if ( spr->textureID != gCurrentTexture )
|
||||
{
|
||||
glBindTexture( GL_TEXTURE_2D, spr->textureID );
|
||||
gCurrentTexture = spr->textureID;
|
||||
}
|
||||
|
||||
glBegin( GL_QUADS );
|
||||
glColor(color);gxTexcoord2i_re( u1, v1 ); gxVertex3i_re( x1, y1, g_depth );
|
||||
glColor(color);gxTexcoord2i_re( u1, v2 ); gxVertex2i_re( x1, y2 );
|
||||
glColor(color);gxTexcoord2i_re( u2, v2 ); gxVertex2i_re( x2, y2 );
|
||||
glColor(color);gxTexcoord2i_re( u2, v1 ); gxVertex2i_re( x2, y1 );
|
||||
glEnd();
|
||||
g_depth++;
|
||||
glColor(0x7FFF);*/
|
||||
glColor(color);
|
||||
glSprite(dx, dy, flipmode, spr);
|
||||
glColor(0x7FFF);
|
||||
}
|
||||
void DrawImageINT(glImage* image, int w, int h, int dx, int dy, int fm) {
|
||||
glSprite(dx, dy, fm, image);
|
||||
}
|
||||
void DrawImageFlippedH (glImage* image, int w, int h, int dx, int dy) {
|
||||
DrawImageINT(image, w, h, dx, dy, GL_FLIP_H);
|
||||
}
|
||||
void DrawImageFlippedHV(glImage* image, int w, int h, int dx, int dy) {
|
||||
DrawImageINT(image, w, h, dx, dy, GL_FLIP_H|GL_FLIP_V);
|
||||
}
|
||||
void DrawImageFlippedV (glImage* image, int w, int h, int dx, int dy) {
|
||||
DrawImageINT(image, w, h, dx, dy,GL_FLIP_V);
|
||||
}
|
||||
void DrawImage(glImage* image, int w, int h, int dx, int dy) {
|
||||
DrawImageINT(image,w,h,dx,dy,0);
|
||||
}
|
||||
void DrawImageCrop(glImage* image, int w, int h, int dx, int dy, int sx, int sy, int dw, int dh) {
|
||||
DrawImage(image, w, h, dx, dy);
|
||||
//DrawRectangle(RED, dx, dy, dw, dh);
|
||||
}
|
||||
void DrawImageCropFlipH(glImage* image, int w, int h, int dx, int dy, int sx, int sy, int dw, int dh) {
|
||||
DrawImageFlippedH(image, w, h, dx, dy);
|
||||
//DrawRectangle(RED, dx, dy, dw, dh);
|
||||
}
|
||||
#undef fv
|
||||
uint16_t GlobalTimer = 0;
|
||||
|
||||
void OnUserCreate();
|
||||
void OnUserUpdate();
|
||||
|
||||
void InitConsoleScreen() {consoleSelect(&bottomScreen);}
|
||||
void PrintChar(char x, char y, char c) { printf("\x1b[%d;%dH%c", y, x, c); }
|
||||
|
||||
void DoEverySecond() {
|
||||
LogMsg("test");
|
||||
}
|
||||
int game_ticks = 0;
|
||||
int millisSinceRun = 0;
|
||||
|
||||
int fpsCounting, fps, prevS;
|
||||
|
||||
#include "bmpfont.h"
|
||||
short font_bmp[1024*8];
|
||||
int fontSpriteID;
|
||||
glImage fontImage[128];
|
||||
|
||||
int main(void) {
|
||||
//videoSetModeSub(MODE_5_2D);
|
||||
lcdMainOnBottom();
|
||||
videoSetMode(MODE_5_3D);
|
||||
videoSetModeSub(MODE_0_2D);
|
||||
|
||||
// init gl2d
|
||||
glScreen2D();
|
||||
glEnable(GL_ANTIALIAS);
|
||||
vramSetBankA( VRAM_A_TEXTURE );
|
||||
vramSetBankB( VRAM_B_TEXTURE );
|
||||
|
||||
soundEnable();
|
||||
|
||||
bgInitSub(2, BgType_Bmp16, BgSize_B16_256x256, 0,0);
|
||||
|
||||
consoleInit(&bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
|
||||
InitConsoleScreen();
|
||||
|
||||
timerStart(0, ClockDivider_1024, 0, NULL);
|
||||
|
||||
glGenTextures(TEXTURE_COUNT, imageIDsReserved);
|
||||
// load font shit
|
||||
decompress(bmpfontBitmap,font_bmp,LZ77);
|
||||
fontSpriteID = glLoadTileSet(fontImage, 6,8,1024,8, GL_RGBA, TEXTURE_SIZE_1024, TEXTURE_SIZE_8, GL_TEXTURE_WRAP_S|GL_TEXTURE_WRAP_T|TEXGEN_OFF|GL_TEXTURE_COLOR0_TRANSPARENT, 0, NULL, (u8*)font_bmp);
|
||||
|
||||
OnUserCreate();
|
||||
while(1) {
|
||||
glBegin2D();
|
||||
fpsCounting++;
|
||||
game_ticks += timerElapsed(0);
|
||||
uint64_t r = game_ticks * 1000llu;
|
||||
r /= TIMER_SPEED;
|
||||
millisSinceRun = r;
|
||||
|
||||
int s = millisSinceRun / 1000;
|
||||
if (prevS != s) {
|
||||
fps = fpsCounting;
|
||||
fpsCounting = 0;
|
||||
}
|
||||
prevS = s;
|
||||
|
||||
prevTouch = touch;
|
||||
touchRead(&touch);
|
||||
scanKeys();
|
||||
|
||||
input_keys = keysCurrent();
|
||||
input_keysUp = keysUp();
|
||||
input_keysDown = keysDown();
|
||||
input_keysHeld = keysHeld();
|
||||
|
||||
OnUserUpdate();
|
||||
char str[100];
|
||||
memset(str,0,100);
|
||||
sprintf(str, "fps: %d", fps);
|
||||
DrawString(2, 184, BLACK, str, 0);
|
||||
DrawString(1, 183, WHITE, str, 0);
|
||||
|
||||
GlobalTimer++;
|
||||
glEnd2D();
|
||||
PushFrame();
|
||||
g_depth = 4000;
|
||||
swiWaitForVBlank();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RectangleContains(Rectangle r, Point p) {
|
||||
return (r.x <= p.x && r.y <= p.y && r.x + r.width > p.x && r.y + r.height > p.y);
|
||||
}
|
||||
|
||||
bool RectangleIntersect(Rectangle r1, Rectangle r2) {
|
||||
int playerX1 = r1.x, playerX2 = r1.x + r1.width, playerY1 = r1.y, playerY2 = r1.y + r1.height;
|
||||
int tileRectX1 = r2.x, tileRectX2 = r2.x + r2.width, tileRectY1 = r2.y, tileRectY2 = r2.y + r2.height;
|
||||
bool noOverlap = tileRectX1 > playerX2 ||
|
||||
playerX1 > tileRectX2 ||
|
||||
tileRectY1 > playerY2 ||
|
||||
playerY1 > tileRectY2;
|
||||
return !noOverlap;
|
||||
}
|
||||
|
||||
/*int dx = x2 - x1;
|
||||
int dy = y2 - y1;
|
||||
|
||||
if (dx >= dy){
|
||||
float y = 0.0f;
|
||||
if(x1 < x2){
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
y = y1 + dy * (x - x1) / dx;
|
||||
PlotPixel(x, y, colour);
|
||||
}
|
||||
}else{
|
||||
for (int x = x2; x <= x1; x++) {
|
||||
y = y1 + dy * (x - x1) / dx;
|
||||
PlotPixel(x, y, colour);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
float x = 0.0f;
|
||||
if(dx == 0){
|
||||
if(y1 < y2){
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
PlotPixel(x1, y, colour);
|
||||
}
|
||||
}else{
|
||||
for (int y = y2; y <= y1; y++) {
|
||||
PlotPixel(x2, y, colour);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(y1 < y2){
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
x = x1 + dx * (y - y1) / dy;
|
||||
PlotPixel(x, y, colour);
|
||||
}
|
||||
}else{
|
||||
for (int y = y2; y <= y1; y++) {
|
||||
x = x1 + dx * (y - y1) / dy;
|
||||
PlotPixel(x, y, colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
#include "Features/RNG.h"
|
||||
#include "Font.h"
|
||||
|
||||
#endif
|
110
source/EngineDec.h
Normal file
@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------------
|
||||
GAME PROJECT
|
||||
[ July 29, 2020 ]
|
||||
Programmed by iProgramInCpp
|
||||
|
||||
EngineDec module
|
||||
---------------------------------------------------------------------------------*/
|
||||
#ifndef ENGINEDEC_H
|
||||
#define ENGINEDEC_H
|
||||
|
||||
#include "Utils.hpp"
|
||||
#include <stddef.h>
|
||||
|
||||
#define TIMER_SPEED (BUS_CLOCK/1024)
|
||||
|
||||
// 16 bit color is structured in 1555 format
|
||||
// EBGR
|
||||
// E - enable bit / alpha
|
||||
// RGBA16
|
||||
|
||||
#define WHITE 0xFFFF
|
||||
#define BLACK 0x0000
|
||||
#define SKY 0xEEEF
|
||||
#define BLUE 0xFC00
|
||||
#define MAGENTA 0xFC1F
|
||||
#define CYAN 0xFFE0
|
||||
#define RED 0x801F
|
||||
#define YELLOW 0x83FF
|
||||
|
||||
//#define RGBA16(r,g,b,a) ((r << 11) | (g << 6) | (b << 1) | a)
|
||||
#define RGBA16(r,g,b,a) ((a << 15) | (b << 10) | (g << 5) | r)
|
||||
#define MakeColor5B(r,g,b) RGBA16(r,g,b,1)
|
||||
#define MakeColor(r,g,b) RGBA16(r/8,g/8,b/8,1)
|
||||
|
||||
#include <nds.h>
|
||||
#include <gl2d.h>
|
||||
|
||||
#define SCREEN_BOTTOM 1
|
||||
#define SCREEN_TOP 2
|
||||
|
||||
#define STYLE_BOLD 0x80
|
||||
#define STYLE_ITALIC 0x40
|
||||
#define STYLE_UNDERLINE 0x20
|
||||
|
||||
#define LAYER_FORE 0
|
||||
#define LAYER_BACK 1
|
||||
|
||||
#define TEXTURE_COUNT 16
|
||||
extern int imageIDsReserved[TEXTURE_COUNT];
|
||||
|
||||
bool GetKeyState(uint32_t button);
|
||||
bool GetKeyDownState(uint32_t button);
|
||||
bool GetKeyUpState(uint32_t button);
|
||||
bool GetKeyHeldState(uint32_t button);
|
||||
void PushFrame();
|
||||
void PlotPixel(int x, int y, short color);
|
||||
void ClearScreen(short color);
|
||||
void FillRectangle(short color, int dx, int dy, int w, int h);
|
||||
void FillRectangleLerp(short c1, short c2, int dx, int dy, int w, int h);
|
||||
void DrawRectangle(short color, int dx, int dy, int w, int h);
|
||||
void DrawLine(int x1, int y1, int x2, int y2, short col);
|
||||
void DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short colour);
|
||||
void FillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short colour);
|
||||
void DrawImageSizable(glImage* image, int w, int h, int dx, int dy, int dw, int dh);
|
||||
void SwitchScreenTop();
|
||||
void SwitchScreenBottom();
|
||||
void DrawImageFlippedH (glImage* image, int w, int h, int dx, int dy);
|
||||
void DrawImageFlippedHV(glImage* image, int w, int h, int dx, int dy);
|
||||
void DrawImageFlippedV (glImage* image, int w, int h, int dx, int dy);
|
||||
void PrintChar(char x, char y, char c);
|
||||
void InitConsoleScreen();
|
||||
uint16_t map(uint16_t min, uint16_t max, uint8_t h);
|
||||
uint16_t color_lerp(uint16_t min, uint16_t max, uint16_t i);
|
||||
void DrawChar(uint16_t x, uint16_t y, char ch, uint16_t color, uint8_t styling);
|
||||
void DrawString(uint8_t x, uint8_t y, uint16_t color, const char* str, uint8_t styling);
|
||||
void DrawImage(glImage* image, int w, int h, int dx, int dy);
|
||||
void DrawImageCrop(glImage* image, int w, int h, int dx, int dy, int sx, int sy, int dw, int dh);
|
||||
void DrawImageCropFlipH(glImage* image, int w, int h, int dx, int dy, int sx, int sy, int dw, int dh);
|
||||
void DrawImageColored(glImage* spr, int w, int h, int dx, int dy, int flipmode, u16 color);
|
||||
|
||||
#define GetBlueComponent(i) (i & 0x7c00) >> 10
|
||||
#define GetGreenComponent(i) (i & 0x03e0) >> 5
|
||||
#define GetRedComponent(i) (i & 0x001f)
|
||||
|
||||
#define Unite(r, g, b) 0x8000 | (b << 10) | (g << 5) | r
|
||||
|
||||
extern touchPosition touch, prevTouch;
|
||||
extern int fps;
|
||||
extern uint16_t GlobalTimer;
|
||||
|
||||
struct Rectangle {
|
||||
int x, y, width, height;
|
||||
};
|
||||
struct Point {
|
||||
int x, y;
|
||||
};
|
||||
typedef Point Point2d;
|
||||
struct Point3d {
|
||||
int x, y, z;
|
||||
};
|
||||
struct Vec3f {
|
||||
float x, y, z;
|
||||
};
|
||||
struct Vec2f {
|
||||
float x, y;
|
||||
};
|
||||
bool RectangleContains(Rectangle r, Point p);
|
||||
bool RectangleIntersect(Rectangle r1, Rectangle r2);
|
||||
|
||||
#endif//ENDINEDEC_H
|
22
source/Features/RNG.h
Normal file
@ -0,0 +1,22 @@
|
||||
unsigned short rng;
|
||||
|
||||
short sky_colour = 0xEEEF;
|
||||
|
||||
unsigned short rng_function(unsigned short input){
|
||||
if(input == 0x560A) input=0;
|
||||
unsigned short S0 = (unsigned char)input<<8;
|
||||
S0 = S0 ^ input;
|
||||
input = ((S0 & 0xFF) << 8) | ((S0 & 0xFF00) >> 8);
|
||||
S0 = ((unsigned char)S0 << 1) ^ input;
|
||||
short S1 = (S0 >> 1) ^ 0xFF80;
|
||||
if((S0 & 1) == 0){
|
||||
if(S1 == 0xAA55){input = 0;}else{input=S1 ^ 0x1FF4;}
|
||||
}else{
|
||||
input = S1 ^ 0x1FF4;
|
||||
}
|
||||
return (unsigned short)input;
|
||||
}
|
||||
|
||||
void rng_update() {
|
||||
rng = rng_function(GlobalTimer);
|
||||
}
|
77
source/Font.h
Normal file
@ -0,0 +1,77 @@
|
||||
#include "Typeface.h"
|
||||
void DrawCharOld(uint16_t x, uint16_t y, char ch, uint16_t color, uint8_t styling)
|
||||
{
|
||||
uint16_t address = ch * 5;
|
||||
uint8_t n = 0;
|
||||
uint16_t new_x = x + n;
|
||||
uint16_t new_y;
|
||||
uint8_t a;
|
||||
uint16_t m = 4;
|
||||
if((styling & STYLE_ITALIC) == 0)
|
||||
{
|
||||
m = 0;
|
||||
}
|
||||
for (n = 0; n < 5; n++)
|
||||
{
|
||||
new_x = x + n;
|
||||
a = MainFont[address + n];
|
||||
if((styling & STYLE_ITALIC) != 0)
|
||||
{
|
||||
m = 4;
|
||||
}
|
||||
for(new_y = 0; new_y < 8; new_y++)
|
||||
{
|
||||
if(a & (0x01 << new_y))
|
||||
{
|
||||
if((styling & STYLE_BOLD) != 0)
|
||||
{
|
||||
PlotPixel(new_x + m + 1, new_y + y, color);
|
||||
}
|
||||
PlotPixel(new_x + m, y + new_y, color);
|
||||
}
|
||||
if((styling & STYLE_ITALIC) != 0 && new_y % 3 == 0) { m--; }
|
||||
}
|
||||
if((styling & STYLE_UNDERLINE) != 0)
|
||||
{
|
||||
PlotPixel(new_x - 1, y + 7, color);
|
||||
PlotPixel(new_x, y + 7, color);
|
||||
PlotPixel(new_x + 1, y + 7, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawChar(uint16_t x, uint16_t y, char ch, uint16_t color, uint8_t styling) {
|
||||
// italic and uline ignored for now, might add it later
|
||||
if (ch >= 128) ch = 127;
|
||||
DrawImageColored(&fontImage[(int)ch], 6, 8, x, y, 0, color);
|
||||
if (styling & STYLE_BOLD) {
|
||||
DrawImageColored(&fontImage[(int)ch], 6, 8, x+1, y, 0, color);
|
||||
}
|
||||
}
|
||||
void DrawString(uint8_t x, uint8_t y, uint16_t color, const char* str, uint8_t styling)
|
||||
{
|
||||
const char* m = str;
|
||||
uint8_t ny = y;
|
||||
uint8_t nx = x;
|
||||
while(*m != 0)
|
||||
{
|
||||
if(*m == '\n')
|
||||
{
|
||||
nx = x;
|
||||
ny += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawChar(nx, ny, *m, color, styling);
|
||||
if((styling & STYLE_BOLD) != 0)
|
||||
{
|
||||
nx += 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
nx += 6;
|
||||
}
|
||||
}
|
||||
m++;
|
||||
}
|
||||
}
|
34
source/Levels.inc.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------------
|
||||
GAME PROJECT
|
||||
[ July 29, 2020 ]
|
||||
ProDrammed by iProDramInCpp
|
||||
|
||||
Level include file
|
||||
---------------------------------------------------------------------------------*/
|
||||
char level_1[] =
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"................................................................................................................................................................................................................................................................"
|
||||
"..{S............................................................................................................................................................................................................................................................"
|
||||
"GGGGGG.........................................................................................................................................................................................................................................................."
|
||||
"GGGGGG..........................................................................................................................................................................................................................................................";
|
||||
char level_1_old[] =
|
||||
"...................................................................................................................................................................................................oo............oo.........oo.................................."
|
||||
".......................................................................................oooooooooooo............................................................................................===================================.............................."
|
||||
"............................?.................................................................................==?==..................................................................=========.........................................1!..................^...."
|
||||
"....................................................................................BBBBBBBBBBBBBBBBBB.................................................................................................................................~`......................."
|
||||
".............................................................................................................................................................................=====....................................................=~`......................."
|
||||
".......................................................................................................................................................................................................................................~`......................."
|
||||
"...^QAL..................BB?^?BB......................1!.......1!.............................................==^==......BB?BBBBBBB?BBBBBB?BB.......1!..............=====...............#.........................................??...~`....1!..........?.?.?.."
|
||||
"...............................................1!.....~`.......~`................BBB........BBBBB...................................................~`..................................#.............................................=~`....~`......8.........."
|
||||
"........................................1!.....~`.....~`.......~`...................................................................................~`......1!..........................#..............................................~`....~`................."
|
||||
"..{S.(......&&...).......&......(...&...~`....)~`.....~`...(...~`............)..........(...&&........)...&.....&...(....&.....&....)......&.&.....(~`).....~`....)....&&.........(.....#...........................................(..~`....~`...&.&.&......).."
|
||||
"GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG.....GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG.........................................GGGGGGGGGGGGGGGGGGGGGGGGGGGG.."
|
||||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD.....DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD.........................................DDDDDDDDDDDDDDDDDDDDDDDDDDDD..";
|
||||
int level_1_width = 256, level_1_height = 12;
|
80
source/Main.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------------
|
||||
GAME PROJECT
|
||||
[ July 29, 2020 ]
|
||||
Programmed by iProgramInCpp
|
||||
|
||||
Main module
|
||||
---------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fat.h>
|
||||
|
||||
#include "Engine.h"
|
||||
#include "Utils.hpp"
|
||||
#include "TestGame.hpp"
|
||||
/*
|
||||
DS Game Engine Function Definitions
|
||||
-- to keep in mind
|
||||
|
||||
bool GetKeyState(uint32_t)
|
||||
bool GetKeyDownState(uint32_t)
|
||||
bool GetKeyUpState(uint32_t)
|
||||
bool GetKeyHeldState(uint32_t)
|
||||
void PushFrame();
|
||||
void PlotPixel(int x, int y, short color)
|
||||
void ClearScreen(short color)
|
||||
void FillRectangle(short color, int dx, int dy, int w, int h)
|
||||
void FillRectangleLerp(short c1, short c2, int dx, int dy, int w, int h)
|
||||
void DrawRectangle(short color, int dx, int dy, int w, int h)
|
||||
void DrawLine(int x1, int y1, int x2, int y2, short col)
|
||||
void DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short colour)
|
||||
void FillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short colour)
|
||||
void DrawImageSizable(short* image, int w, int h, int dx, int dy, int dw, int dh)
|
||||
void SwitchScreenTop()
|
||||
void SwitchScreenBottom()
|
||||
void DrawImageFlippedH(short* image, int w, int h, int dx, int dy)
|
||||
void DrawImageFlippedHV(short* image, int w, int h, int dx, int dy)
|
||||
void DrawImageFlippedV(short* image, int w, int h, int dx, int dy)
|
||||
void PrintChar(char x, char y, char c);
|
||||
void InitConsoleScreen();
|
||||
*/
|
||||
bool isFileSystemEnabled = false;
|
||||
void OnUserCreate()
|
||||
{
|
||||
/*isFileSystemEnabled = fatInitDefault();
|
||||
FILE* f = fopen("/test.txt", "r");
|
||||
char s [15];
|
||||
memset(s,0,15);
|
||||
if (!f) {
|
||||
LogMsg("Unable to open file");
|
||||
} else {
|
||||
fread(s, 1, 14, f);
|
||||
fclose(f);
|
||||
LogMsg("Got string: %s", s);
|
||||
}*/
|
||||
//SwitchScreenBottom();
|
||||
//SwitchScreenTop();
|
||||
//InitConsoleScreen();
|
||||
printf("\n\n\n\n\n\n\n\n");
|
||||
printf(" Growalone Maker V%.2f ", 0.10); // game version
|
||||
printf(" For Nintendo DS / DSi ");
|
||||
//printf(" This is intended for use with ");
|
||||
//printf("the touch screen. Please look at");
|
||||
//printf(" the bottom screen now. ");
|
||||
//printf(" There is NOTHING to see here...");
|
||||
printf("\n");
|
||||
printf("NOTE: You can't save. This is a ");
|
||||
printf("prototype. Saving will be added ");
|
||||
printf(" later.... ");
|
||||
|
||||
Game::Init();
|
||||
Game::LoadContent();
|
||||
}
|
||||
|
||||
|
||||
void OnUserUpdate()
|
||||
{
|
||||
rng_update();
|
||||
//ClearScreen(RGBA16(0, 12, 31, 1));
|
||||
Game::Update();
|
||||
}
|
31
source/Map.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
// returns an integer between min and max using range from 0-255
|
||||
uint16_t map(uint16_t min, uint16_t max, uint8_t h)
|
||||
{
|
||||
uint16_t i = max - min;
|
||||
if(h == 0x00) return min;
|
||||
else if(h == 255) return max;
|
||||
else
|
||||
{
|
||||
uint16_t m = min + (h * i / 256);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t color_lerp(uint16_t min, uint16_t max, uint16_t i)
|
||||
{
|
||||
uint8_t mred = GetRedComponent(min);
|
||||
uint8_t mgreen = GetGreenComponent(min);
|
||||
uint8_t mblue = GetBlueComponent(min);
|
||||
|
||||
uint8_t m2red = GetRedComponent(max);
|
||||
uint8_t m2green = GetGreenComponent(max);
|
||||
uint8_t m2blue = GetBlueComponent(max);
|
||||
|
||||
uint8_t rred = map(mred, m2red, i);
|
||||
uint8_t rgreen = map(mgreen, m2green, i);
|
||||
uint8_t rblue = map(mblue, m2blue, i);
|
||||
|
||||
return Unite(rred, rgreen, rblue);
|
||||
}
|
1427
source/TestGame.cpp
Normal file
49
source/TestGame.hpp
Normal file
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------------
|
||||
GAME PROJECT
|
||||
[ July 29, 2020 ]
|
||||
Programmed by iProgramInCpp
|
||||
|
||||
TestGame module
|
||||
---------------------------------------------------------------------------------*/
|
||||
#include "EngineDec.h"
|
||||
#include "Utils.hpp"
|
||||
|
||||
#ifndef TESTGAME_HPP
|
||||
#define TESTGAME_HPP
|
||||
|
||||
//extern short tiles[128*128];
|
||||
//extern short character[128*16];
|
||||
//extern short clapperboard[128*64];
|
||||
extern glImage tilesImage[64];
|
||||
extern int BlockBumpedX, BlockBumpedY;
|
||||
extern float fPlayerPosX, fPlayerPosY;
|
||||
extern float maxTime;
|
||||
extern int gems, score;
|
||||
extern float inGameTime;
|
||||
extern int nLevelWidth, nLevelHeight;
|
||||
namespace Game {
|
||||
void UpdateGameLogic(float fElapsedTime);
|
||||
void Update();
|
||||
void Draw();
|
||||
void Init();
|
||||
void LoadContent();
|
||||
};
|
||||
namespace Title {
|
||||
void Update();
|
||||
void Init();
|
||||
void LoadContent();
|
||||
};
|
||||
void DrawTile(char sTileID, int x, int y, char sTileIDAbove = '.', bool renderInInventory = true, int tileX = 0, int tileY = 0);
|
||||
#define DIR_UP 0x01
|
||||
#define DIR_DOWN 0x02
|
||||
#define DIR_LEFT 0x04
|
||||
#define DIR_RIGHT 0x08
|
||||
bool IsSolid(char c, int directions);
|
||||
char GetTile(int x, int y);
|
||||
void SetTile(char c, int x, int y);
|
||||
void IncreaseMaxHP();
|
||||
void DamagePlayer();
|
||||
void HealPlayer();
|
||||
typedef void DialogResultFunction(bool); // the bool represents saidYes
|
||||
void ShowDialog(DialogResultFunction* f, const char* dialogYes, const char* dialogNo, const char* dlgRow1, const char* dlgRow2 = nullptr, const char* dlgRow3 = nullptr);
|
||||
#endif//TESTGAME_HPP
|
259
source/Typeface.h
Normal file
@ -0,0 +1,259 @@
|
||||
const char MainFont[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||
0x1F, 0x0F, 0x3E, 0xCC, 0x08, //0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||
0x7E, 0x99, 0xA5, 0xA5, 0x7E,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||
0x22, 0x54, 0x54, 0x78, 0x42,
|
||||
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||
0x7D, 0x12, 0x11, 0x12, 0x7D,
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||
0x3A, 0x44, 0x44, 0x44, 0x3A,
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||
0x3D, 0x42, 0x42, 0x42, 0x3D,
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||
0x55, 0x00, 0x55, 0x00, 0x55,
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA,
|
||||
0xFF, 0x55, 0xFF, 0x55, 0xFF,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||
0xFC, 0x4A, 0x4A, 0x4A, 0x34,
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
20
source/Utils.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
/*---------------------------------------------------------------------------------
|
||||
GAME PROJECT
|
||||
[ July 29, 2020 ]
|
||||
Programmed by iProgramInCpp
|
||||
|
||||
Utils module
|
||||
---------------------------------------------------------------------------------*/
|
||||
#include "Utils.hpp"
|
||||
|
||||
void LogMsg(const char* s, ...) {
|
||||
|
||||
char c[10240];
|
||||
va_list v;
|
||||
va_start(v, s);
|
||||
memset(c,0,sizeof(c));
|
||||
vsprintf(c, s, v);
|
||||
va_end(v);
|
||||
puts(c);
|
||||
|
||||
}
|
11
source/Utils.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
/*---------------------------------------------------------------------------------
|
||||
GAME PROJECT
|
||||
[ July 29, 2020 ]
|
||||
Programmed by iProgramInCpp
|
||||
|
||||
Utils module
|
||||
---------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cstdarg>
|
||||
void LogMsg(const char* m, ...);
|