7 Replies - 536 Views - Last Post: 24 October 2011 - 11:58 AM Rate Topic: -----

#1 envy06  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-October 11

How to place a platform without seeing it at the screen

Posted 14 October 2011 - 10:54 PM

Hi guys. I just want to ask how to put a 2d platform without you seeing it on screen. what i mean is if the platform you want to put is way ahead on the character. Just like in the game super mario. thanks
Is This A Good Question/Topic? 0
  • +

Replies To: How to place a platform without seeing it at the screen

#2 Bench  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 944
  • View blog
  • Posts: 2,464
  • Joined: 20-August 07

Re: How to place a platform without seeing it at the screen

Posted 15 October 2011 - 12:35 AM

C++ doesn't have any concept of a "screen" or a "platform", so the first thing you need to do is have a think about what you mean by these. Are you using a library which defines them for you?
Was This Post Helpful? 0
  • +
  • -

#3 Gungnir  Icon User is offline

  • Your Imaginary Friend

Reputation: 152
  • View blog
  • Posts: 527
  • Joined: 21-May 11

Re: How to place a platform without seeing it at the screen

Posted 15 October 2011 - 03:30 AM

Step 1: Digitize your Height/Width assets. For example, use 64x64 tiles.
Step 2: Build a virtual map (basically data to tell your tile-drawing function where to draw tiles).
Step 3: Use SDL_Rect's to help you check collision between objects.
Step 4: Set your characters movement so that the tiles and rects move instead of your character moving.

Now you can build a map of any size/shape with a little foundation work that's independent of what's visible on the "screen". The stuff is still there (and still uses resources), it's just not being drawn.

If you're having trouble conceiving the idea of an interaction layer, draw a rectangle around the object that you want to interact with. (your "platform")

This isn't the only answer, it doesn't detail the entire job, and it's nowhere near the best answer, but it's easy, it puts you in the right direction, and with a little initiative and some debugging patience you should be able to at least put your ideas down and get some output.

EDIT: Sorry, I'm assuming that you're using SDL.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6245
  • View blog
  • Posts: 24,013
  • Joined: 23-August 08

Re: How to place a platform without seeing it at the screen

Posted 15 October 2011 - 04:33 AM

Moved to Game Programming
Was This Post Helpful? 0
  • +
  • -

#5 Greltam  Icon User is offline

  • D.I.C Head

Reputation: 91
  • View blog
  • Posts: 225
  • Joined: 29-January 09

Re: How to place a platform without seeing it at the screen

Posted 15 October 2011 - 08:25 AM

load all your resources/objects into your map or level, create a camera class with bounds the size of the screen, make the camera focus on the player/move with the player, draw everything that collides with the camera( Your draw method on your objects should take in an offset, which subtracts the offset from their position, yielding the absolute coordinate to draw on the screen).
example:
Player is at x = 1000, y = 400.
Camera(Screen) size is width = 800, height = 600.
Camera is centered on Player, making Camera at x = 600, y = 100.
For all objects that collide with Camera(x between 600 & 1400, y between 100 & 700)
draw object with offset of Camera x, Camera y.
{Say object x = 800, y = 500, object drawn on the screen would be at:
x = 200(obj800 - cam600)
y = 400(obj500 - cam100)
}

This post has been edited by Greltam: 15 October 2011 - 08:27 AM

Was This Post Helpful? 1
  • +
  • -

#6 envy06  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-October 11

Re: How to place a platform without seeing it at the screen

Posted 24 October 2011 - 02:48 AM

Thanks for the tips. I'm basically new to darkGDK and want to try this out. But i do have background with programming. C++ and C# as well as java. actually I don't know what SDL means and i haven't encountered it yet. But i'm using darkGDK. ^^

View PostGreltam, on 15 October 2011 - 08:25 AM, said:

load all your resources/objects into your map or level, create a camera class with bounds the size of the screen, make the camera focus on the player/move with the player, draw everything that collides with the camera( Your draw method on your objects should take in an offset, which subtracts the offset from their position, yielding the absolute coordinate to draw on the screen).
example:
Player is at x = 1000, y = 400.
Camera(Screen) size is width = 800, height = 600.
Camera is centered on Player, making Camera at x = 600, y = 100.
For all objects that collide with Camera(x between 600 & 1400, y between 100 & 700)
draw object with offset of Camera x, Camera y.
{Say object x = 800, y = 500, object drawn on the screen would be at:
x = 200(obj800 - cam600)
y = 400(obj500 - cam100)
}


Question sir.. does this means i'm gonna use the 3d of darkGDK for the camera function to operate?
Was This Post Helpful? 0
  • +
  • -

#7 Greltam  Icon User is offline

  • D.I.C Head

Reputation: 91
  • View blog
  • Posts: 225
  • Joined: 29-January 09

Re: How to place a platform without seeing it at the screen

Posted 24 October 2011 - 05:36 AM

Depends, how would you draw your objects normally?
Was This Post Helpful? 0
  • +
  • -

#8 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: How to place a platform without seeing it at the screen

Posted 24 October 2011 - 11:58 AM

View Postenvy06, on 24 October 2011 - 10:48 AM, said:

I don't know what SDL means and i haven't encountered it yet.


SDL is a graphics library and Gungnir assumed you were using it (why?). In future you should post which library or SDK you are using and some example code. It makes it a lot easier for people to help you :)

Different API's, library's and SDKs will have different ways to achieve what you want to do. If you really just want an invisible platform then you don't need to do any drawing, check your collision code and just add a rectangle/cube. You don't need to add this to your drawing code at all it's just some values for you to check collision against.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1