[DevLog] Coin Hunt

Started by troutsneeze, Jan 24, 2023, 05:24 PM

Previous topic - Next topic

troutsneeze

I started making a proper demo for BooBoo.

The attached game will run with the latest version of BooBoo. So far you can fly around a star field. The plan is to add some enemies and coins (the objective is to find all the coins.)

Here is the code:

number size_w
number size_h

= size_w 4
* size_w 640
= size_h 4
* size_h 360

number pos_x
number pos_y
= pos_x size_w
/ pos_x 2
= pos_y size_h
/ pos_y 2

number ship_a
= ship_a 0

number real_a

number ship_acc
= ship_acc 0

number ship_vel
= ship_vel 0

number ship_img
image_load ship_img "misc/ship.png"

number ox
number oy

number num_stars
= num_stars 1024
vector stars
number i
= i 0
:add_another_star
vector star
number star_w
= star_w size_w
- star_w 1
number star_h
= star_h size_h
- star_h 1
number star_x
number star_y
rand star_x 0 star_w
rand star_y 0 star_h
vector_add star star_x
vector_add star star_y
vector_add stars star
+ i 1
? i num_stars
jl add_another_star

function calc_offset
{
= ox pos_x
- ox 320
? ox 0
jge do_x_offset2
= ox 0
:do_x_offset2
number max_x
= max_x size_w
- max_x 640
? ox max_x
jle do_y_offset
= ox max_x

:do_y_offset
= oy pos_y
- oy 180
? oy 0
jge do_y_offset2
= oy 0
:do_y_offset2
number max_y
= max_y size_h
- max_y 360
? oy max_y
jle done_offset
= oy max_y

:done_offset
}

function calc_real_a
{
= real_a 3.14159
* real_a 6
/ real_a 4
+ real_a ship_a
}

function draw
{
clear 0 0 0

call calc_offset

number i
= i 0
start_primitives
:draw_next_star
vector star
vector_get stars star i
number star_x
number star_y
vector_get star star_x 0
vector_get star star_y 1
- star_x ox
- star_y oy
filled_rectangle 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 star_x star_y 1 1
+ i 1
? i num_stars
jl draw_next_star

end_primitives

number xx
= xx pos_x
- xx ox
number yy
= yy pos_y
- yy oy

image_draw_rotated_scaled ship_img 255 255 255 255 8 8 xx yy ship_a 1 1 0 0
}

function run
{
+ ship_vel ship_acc
? ship_vel 8
jle done_clamp
= ship_vel 8

:done_clamp

? ship_acc 0
jne done_vel_damp
- ship_vel 0.1
? ship_vel 0
jge done_vel_damp
= ship_vel 0

:done_vel_damp

include "poll_joystick.inc"

= ship_acc 0
? joy_a 0
je done_thrust
= ship_acc 0.1
:done_thrust

call calc_real_a

number f

= f real_a
cos f f
* f ship_vel
+ pos_x f

= f real_a
sin f f
* f ship_vel
+ pos_y f

? pos_x 0
jge x_ok1
= pos_x 0
:x_ok1
number max_x
= max_x size_w
- max_x 1
? pos_x max_x
jle x_ok2
= pos_x max_x
:x_ok2

? pos_y 0
jge y_ok1
= pos_y 0
:y_ok1
number max_y
= max_y size_h
- max_y 1
? pos_y max_y
jle y_ok2
= pos_y max_y
:y_ok2

number a_inc
= a_inc 0

? joy_l 0
je no_rot_l
- a_inc 0.1
:no_rot_l
? joy_r 0
je no_rot_r
+ a_inc 0.1
:no_rot_r

+ ship_a a_inc
}

troutsneeze

I added some things.

- Randomly placed coins you can pick up
- Some enemies moving around
- Some other things like a buffer around the edges

troutsneeze

The latest builds are too big to attach due to the inclusion of a font. You can grab them from git at https://github.com/troutsneeze/BooBoo in examples/game_lib/coin_hunt.

There's now a status bar at the top that shows how many coins you've collected and your time. You can shoot bullets which will destroy enemies and coins (but you're not supposed to destroy coins and you will die if you do.)