Example

Following camera concept demo thingy

9

Hey, I did a thing. 2020-08-30 06:12 (Edited)

Basically, this poorly written pile of unorganised spaghetti is a “test concept demo” for a way of making the screen camera follow the player.

The reason a moving camera is a difficult feature to create in a program (at least, for me it is) is because the ‘background scroll’ command moves the background/camera in Increments of 8 pixels or 1 cell at a time and this results in jittery camera movement which looks bad. And the ‘scroll’ command moves the background in single pixel measurements but the location of the cells in the background stay the same resulting in invisible walls when using the ‘cell.c(cx,cy)=c’ string to detect cells/walls or blocks in a game.

So, the solution is to use the ‘scroll’ command to move the background to follow the player. And use the text bellow to detect if there is an interaction between the player and the background.

if cell.c((scroll.x(backgroundLayer)+playerXposition)/8,(scroll.y(backgroundLayer)+playerYposition)/8)=GameWallCharacter then (your player is colliding with a wall)

Also, please tell me if you know any better or simpler ways of detecting if a sprite is colliding with a cell. The cell.c command is long and has some flaws. Like how it only detects cells at a single point, not an area or surface.


—-ALL MY EXISTING UNFINISHED PROJECTS HAVE BEEN DISCONTINUED-—


Timo 2020-08-30 07:15

Here is my solution: https://lowresnx.inutilis.com/topic.php?id=318

The code is commented.


was8bit 2020-08-30 10:06

I highly recommend using Timo's code for this... it is what I do, and it works perfectly :)


was8bit 2020-08-30 10:12

Alternatively, to simplify the code entirely, you can restrict movement to single cell movement, but movement is jerky (like I do in my Space Invaders game).. OR you can restrict smooth movement that begins and ends directly inside each cell (like I do in my DnD game)

Either approach does NOT allow movement to end in between cells... it is not as smooth and natural Timo's code, but it is a less complicated approach....

If you can understand and are able to use Timo's code it is the best appoach :)


was8bit 2020-08-30 10:13

I LOVE your graphics BTW :D


GAMELEGEND 2020-08-30 13:01 (Edited)

these graphics are awesome


Hey, I did a thing. 2020-09-06 01:26

Thanks Timo for showing me your method. It seems pretty reliable, Once I learn how it works I’m definitely going to use it.


Hey, I did a thing. 2020-09-06 01:26

Thanks Timo for showing me your method. It seems pretty reliable, Once I learn how it works I’m definitely going to use it.


Log in to reply.