Welcome to my blog! Below are the most recent posts. From the Menu you will see Posts (excluding series) and Series which go through detail in building part of a game or a whole game.
Get Setup
Intro
This tutorial we will setup your Raylib-go dev environment and create a project which will produce a blank window. Then we continue in this series building on this project until we complete our first Raylib go game.
You can scroll down on awesome-go to the contents and find and click on game development or click this link
You can follow along on this tutorial and at the bottom of this post there are a few useful links including [A Video series to build a Animal Crossing style game] (https://www.youtube.com/watch?v=iWp-mCIQgMU&list=PLVotA8ycjnCsy30WQCwVU5RrZkt4lLgY5&index=1)
By Richard Porteous
read moreScreen wrap & Detect edges
Wrap and follow
We finish up this mini series with this post. The basic game will be functional with these last two changes in the game. I don’t want to get into game design or polishing up this ‘demo’ to turn it into a full fun game. That I will let you try using examples from elsewhere.
Choices
In earlier experimenting I had the tail following the head but when I added the screen-wrap it broke.
So let’s add wrap first and see if that makes it simpler.
Adding wrap
Ok we use math here and I’m not going to explain much.
- copysign tells us if the number is negative or positive.
- abs gives a positive value (absolute value)
Finding center requires a math formula and a simple search will give you the answer you need.
tpos is tilepos - cryptic yes - you could expand the name to make clearer
############################
##### Helper Functions #####
############################
def get_tpos_from_pos(pos):
axs = int(math.copysign(1,pos[0]))
ays = int(math.copysign(1,pos[1]))
return axs * int(abs(pos[0])/TILESIZE[0]), ays * int(abs(pos[1])/TILESIZE[1])
def get_pos_from_tpos(tpos):
axs = int(math.copysign(1,tpos[0]))
ays = int(math.copysign(1,tpos[1]))
return axs * (abs(tpos[0]) * TILESIZE[0] + int(TILESIZE[0]/2)), ays * (abs(tpos[1]) * TILESIZE[1] + int(TILESIZE[1]/2))
def calc_current_tile_axis_center_pos(pos_axis):
axs = int(math.copysign(1,pos_axis))
return axs * int(abs(pos_axis)/TILESQRT) * TILESQRT + int(TILESQRT/2)
By Richard Porteous
read moreGrid Movement
Grid Movement
There is a few different ways to do this and each way gives you slightly different results.
I wanted a method that would detect when I crossed the center of a tile or landed on it.
I came up with this for going left - I could have started with right, up, or down I guess.
By Richard Porteous
read more