Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to make the player walk up and down diagonal platforms

Jason

Awesome Bro

Hmm...

So I can't figure this out to save my life, I've drawn the hearts I'll be using to display lives, and I've set it out like this;

If lives are equal to 2 (This is just for an example)
   ^
   Draw the lives as image
   Draw number of lives
   v

And each time the player collides with an enemy (Just using some spikes at the mo), I've made it do "Set lives: -1"

But nothing even displays at all, even before I hit the spikes or anything...

Does anyone know how to properly display lives like this ?

Cheers.

So I don't know how to really put a name to this problem for the title... but what I'm trying to do is;

When you jump on an enemies head, the enemy dies, but if you hit it from the side, you lose a life...

Now, I know how to make it so the player loses a life, or so the enemy "dies", but what I don't know is how to check the position of the player, like how to check if you're on the enemies head, or side...

I would prefer if someone could make a demo for it, as well as explain how it was done, although either will work as long as it's clear enough for me to follow,

Cheers.

So instead of having just plain flat surfaces to walk on, I've decided to have bumpy floors (Simulating the ourdoors), and diagonal sloped floors,

However, the problem is that as soon as it comes to a bumpy surface or diagonal floor, my player just stops completely and won't budge...

Same as before, if someone could make me a demo and/or explain it as simple as possible, I'd be very grateful,

Cheers.
 
Hmm, couldn't you do like a variable?

Like
Conditional branch
if variable "lives" = 0 then "game over"
if variable "lives" = 1 then show picture "hearts1"
if variable "lives" = 2 then show picture "hearts2"
etc?

Then maybe put it in a common event?
 
You just have to use the "Set Lives" command, which is best done in a Create event. You can alternatively edit the variable "lives". Then in a Draw event, use the "Draw Life Images" command. You shouldn't need to check variables at all for this. To subtract lives, you can use the "Set Lives" command and set it to -1 with "Relative" checked. Then put the "Test Lives" command in a Step event to check when the lives are at 0 so you can end the game.

I can do screenshots or whatever you need if that isn't clear enough. ^_^
 
I was wrong about the Step event; I didn't know there was a "No More Lives" event. :P

This is a lot easier if I just send you a project in which I simulated the basics of what you want (I think). Three objects - the controller, the player, and a spike. Just hit the right button to make the player run into the spike and it'll take away a life. And when all are gone it shows a "Game Over" message and shuts down. It's minimal, but it should show you how to do what you want with lives.

Link: http://bb.ohsk.net/uploads/jbristlives.zip

The controller objects is what I always use. You could theoretically just transfer the events to the player, but I prefer to have something room-specific in case there are variations later on.
 

Jason

Awesome Bro

Ah I see, that was really simple to set up lol, thanks for the help,

Now instead of making a new thread, I'm going to ask a different question on this one (I'll edit the main post)
 
Hehe...you should take a look at this tutorial. I'll make something for ya, but that's where I learned all of this. ;)

Link: http://bb.ohsk.net/uploads/jbristcollision.zip

It's basically just a matter of checking the player's position when they collide with the object. I included a bunch of basic platformer stuff - jumping, gravity, etc. which you can get probably get a better explanation from that tutorial I linked to. Let me know if you have any problems. ^_^
 

Jason

Awesome Bro

Holy cow that's really simple too lol, I didn't think of that either, haha.

Is there a way to check which side of the enemy you're at if you hit it from the side ?

Because on yours, no matter which side you walk into it from, it makes you move 30 pixels to the right, and if you walk into it from the left, that'd just make you hit it again and lose another life.
 
Yeah I was too lazy to work on that. XD Just do a variable check for the player's direction.

0 = right
90 = up
180 = left
270 = down

Then you can do movement based on that. So...

If "direction" of player is 0
--Move x:30
If "direction" of player is 180
--Move x:-30

It's pretty much just a bunch of busy work with checking the direction of the player. You can do ranges if you use the "greater than" and "less than" options instead of "equal to", although that's a bit more work. :3
 

Jason

Awesome Bro

Ah I see, well that's that question answered anyways...

I wonder why the directions are so weird like that, I mean, personally I'd have started from the top as 0 and work clockwise, lol.
 

Jason

Awesome Bro

Ooh, I've just found a problem with the lives thingy actually... didn't notice it before since I had my "views" set differently

So what it is, is that I have the lives displayed in the top left corner of the screen, but I've just set my view so that the game screen res is smaller, and the camera follows the player, who is centered in the middle... I think you know where this is going...

Is there a way to like, stick it to the screen so that it's always there even while moving around ?

If that doesn't make sense, I'll try to explain it better.
 
Yeah. Just set the position of the life images to...

X: view_xview
Y: view_yview

view_xview and view_yview are pre-defined variables that will put something in the view area. You can also use operations within the x and y values (i.e. make it "view_xview+50" to move it to the right). I actually didn't know those variables existed before I checked something. :P
 

Jason

Awesome Bro

Hmm, that didn't do anything, and I even changed the xview and yview to 0 to see if I actually had to fill something in there, and it said the variables weren't defined o.O

Any ideas ?
 
Are you sure you've got it like this?:
Capture.PNG

It works fine for me. If that's not the problem I can upload the updated version of that so you can check things.
 

Jason

Awesome Bro

Hmm, well mines exactly the same, I guess that mean it's only available on the Pro version, which is too bad since at the moment I literally have no money at all to pay for it, lol.
 

Jason

Awesome Bro

Hmm, what the fuck, nevermind my last post...

So I've been using "View 1", and I thought, the only difference between yours and mine, is that you're using View 0, so I tried changing the code to view1_xview etc, and I got an error...

... So I changed my view 1 to view 0, and it works fine now, what the fuck o.O
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top