Dusting off someo old code
DanielH

{"name":"613261","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/8\/98fdd80ee415991f4b9db7f5a2a652cc.png","w":601,"h":377,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/8\/98fdd80ee415991f4b9db7f5a2a652cc"}613261

I was going through some files and found this from 2013. I started it for Allegro 4. About the same time 5 came out. I decided to start over and recode it for 5 to help learn the newer API.

Never got far, but it's a cute little game. Surprising it compiled after adding a few missing 'const'.

If you compile it, it uses addons: image, primitives, native dialog, audio, audio codec, font, ttf

Left/right arrows to move left or right
Up to Jump
Down to crouch (or for power jump. It's implemented, but not added in the included map)
Space to spit fire (after you get power up)

Compile with _DEBUG to skip intro screen and the power up dialogs. Also includes the map editor if compiled in debug mode.

For kicks, I included what I had for Allegro 4 before I switched.

Edgar Reynaldo

I'm too lazy to compile it. Can you whip up a makefile or a CMakeLists.txt for me? Pretty please?

DanielH

I've never used CMake but this might work

cmake_minimum_required(VERSION 2.8.9)
project(myric)

include_directories(include)

file(GLOB SOURCES "src/*.cpp")

add_executable(myric ${SOURCES})

Peter Hull
DanielH said:

I've never used CMake but this might work

You wish!

At a minimum it needs to mention Allegro somewhere! This works for me on Mac but I suspect it won't on Windows because they don't have pkg-config. So much for "cross-platform make"

cmake_minimum_required(VERSION 3.23)
find_package(PkgConfig)
project(myric)

pkg_check_modules(ALLEGRO REQUIRED
  allegro_image-5
  allegro_primitives-5
  allegro_dialog-5
  allegro_audio-5
  allegro_acodec-5
  allegro_font-5
  allegro_ttf-5
  allegro_main-5
  allegro-5)

file(GLOB SOURCES "src/*.cpp")

add_executable(myric ${SOURCES})
target_link_libraries(myric ${ALLEGRO_LINK_LIBRARIES})
target_include_directories(myric PUBLIC include ${ALLEGRO_INCLUDE_DIRS})
target_compile_options(myric PUBLIC ${ALLEGRO_CFLAGS})

Every time I use CMake I am reminded what a shit-show it is.

[edit]
Forgot to say, for Mac you need to rename App::main to App::app_main everywhere because Mac uses some kind of magic main that #defines the word 'main' to something else.
Also it won't work on Linux either because

/tmp/Myric/src/game.cpp:9:10: warning: non-portable path to file
      '"objectlist.h"'; specified path differs in case from file name on disk
      [-Wnonportable-include-path]
#include "objectList.h"
         ^~~~~~~~~~~~~~
         "objectlist.h"

(if that sounded a bit harsh I didn't mean it, it's impressive there's just those couple of things! ;D )

DanielH

Ha Ha!

I spaced it and forgot a few things.

Thanks anyways!

Edgar Reynaldo

Cool! Nice functioning little platformer. I managed to find some an out of bounds area and to hang the program. Ooops!

DanielH

It wasn't finished. I vaguely remembering the map being more complete.

There are more power ups. Like those purple squares with up arrows. If you get the power up, you can crouch on those squares. After a couple seconds, you start flashing and can do a super jump.

Everything was so close together that getting all the power ups was too quick. I think I deleted that map and started over. Plans were also to add more mobs than those blobs jumping around.

The map size was solid and was one big array of cells. Each area was marked off and when you entered a new area, it would calculate where the edges were. Each cell had 8 layers. You're actually starting on the 3rd or 4th layer. The black doors were how you go up or down layers (pressing up).

Edgar Reynaldo

It may be incomplete, but you've got all the mechanics down it seems. Looks like all you have to do now is add content and you've got yourself a nice little game!

Did you have a hard time porting from A4 to A5?

DanielH

Not really. Just getting used to an event based system and the differences in function names. The documentation was always up.

Thread #618726. Printed from Allegro.cc