Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Game map
Started by BulkOlav Oct 08 2018 09:20 AM

12 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 11 posts
  • Corona SDK

Hi- Is it possible to make a backround that is significantly lager than a phone screen so that the player can move around sort of like a level/map. I want the content area to follow the player as he/she moves around on the backround. I was just wondering if this is possible in corona?

 

 



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,093 posts
  • Corona SDK

Yes and no.

 

This isn't a Corona limitation. It is a question of hardware capability.

 

Example 1 - iPhone 5

  • Pixel resolution of the screen is 1136 x 640
  • Supports a maximum texture size of 4096 x 4096.

This means that a single un-scaled texture is the equivalent of:

  • 6.4 screen widths
  • 3.6 screen heights

So, as long as your world is not larger than that, you can using a single texture for the world map.

 

 

Example 2 - iPad Pro

  • Pixel resolution of the screen is 2732 x 2048
  • Supports a maximum texture size of 4096 x 4096 (this may be wrong; memory tells me this should be 8192 x 8192, but online I found 4K x 4K)

This means that a single un-scaled texture is the equivalent of:

  • 2 screen widths
  • 1.49 screen heights

So, as long as your world is not larger than that, you can using a single texture for the world map.

 

 

Big Problem

The big problem with thinking this way however is you are limited to hardware that supports your image size.

 

It is better to use image sizes that are commonly supported.  Today, the most commonly supported size (most device) is 2048 x 2048.  

 

So, making up a map of multiple textures is better.

 

On top of that, using smart techniques to page textures in and out of memory is also smart.

 

 

Resolution and Max Texture Sizes Source:  http://iosres.com/


Edited by roaminggamer, 08 October 2018 - 09:58 AM.


[TOPIC: post.html]
#3

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 11 posts
  • Corona SDK

Thank you for the answer :)

 

Could you elaborate on these smart techniques? I am not quite sure what I should do, because I belive that a big map is somewhat essensial to this game. I think 2048 x 2048 is enough, but if there is an easy alternative to make this bigger, then that would be nice in terms of gameplay and such.

 

Really appreciate your help on my previous question and this roaminggamer:)



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,093 posts
  • Corona SDK

I mean you'd have to set up your own:

  • scene management code to draw backgrounds as needed
  • scene managment code to remove images that are not in view any more to reduce memory usage on your device
  • .. more

Sorry, but this is not something that can be described or shown in just a few lines of description or code.  There are just too many ways to handle drawing an endless or large-but-limited sized world.

 

Personally, I suggest you consider a Tiled based solution like PonyTiled.

 

Warning: You're still going to have to learn and understand a bunch of stuff.  As well, you will need to modify the solution to suit your needs.

 

PS - Can you link a few YouTube  videos of games that you feel are representative of the kind of thing you are trying to do/make?  If we can see what you want to achieve, we might be able give better advice.


Edited by roaminggamer, 08 October 2018 - 02:14 PM.


[TOPIC: post.html]
#5

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 11 posts
  • Corona SDK

Alright that does sound a bit complicated for a noob like me so i'll just stick with your recommendation and use 2048 x 2048.

 

One thing i have been looking for on the forum is how to keep the screen moving with the player in fokus. If you have an answer for that aswell while I have your attention, then that would be absolutely wonderfull. 

 

After that I will have a lot to work with and won't bother the forum for a while :)



[TOPIC: post.html]
#6

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,093 posts
  • Corona SDK

What you're talking about is a camera.

 

SSK provides multiple types of camera:  https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/camera/

 

You probably want this once: https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/camera/#tracking

 

You can see an example of me setting up a dummy scene and the in the validation code that come with SSK: https://github.com/roaminggamer/SSK2/raw/master/validation.zip

 

https://raw.githubusercontent.com/roaminggamer/SSK2/master/validation/tests/camera/001_tracking.lua

-- =============================================================
-- Copyright Roaming Gamer, LLC. 2008-2016 (All Rights Reserved)
-- =============================================================

-- =============================================================
-- Localizations
-- =============================================================
-- Lua
local getTimer = system.getTimer; local mRand = math.random
local mAbs = math.abs
local strMatch = string.match; local strGSub = string.gsub; local strSub = string.sub
--
-- Common SSK Display Object Builders
local newCircle = ssk.display.newCircle;local newRect = ssk.display.newRect
local newImageRect = ssk.display.newImageRect;local newSprite = ssk.display.newSprite
local quickLayers = ssk.display.quickLayers
--
-- Common SSK Helper Modules
local easyIFC = ssk.easyIFC;local persist = ssk.persist
--
-- Common SSK Helper Functions
local isValid = display.isValid;local isInBounds = ssk.easyIFC.isInBounds
local normRot = math.normRot;local easyAlert = ssk.misc.easyAlert
--
-- SSK 2D Math Library
local addVec = ssk.math2d.add;local subVec = ssk.math2d.sub;local diffVec = ssk.math2d.diff
local lenVec = ssk.math2d.length;local len2Vec = ssk.math2d.length2;
local normVec = ssk.math2d.normalize;local vector2Angle = ssk.math2d.vector2Angle
local angle2Vector = ssk.math2d.angle2Vector;local scaleVec = ssk.math2d.scale
ssk.misc.countLocals(1)

-- =============================================================
-- =============================================================

-- PLUGIN REQUIRES GO HERE

-- =============================================================
local test = {}

function test.run( group, params )
   group = group or display.currentStage
   params = params or {}

   -- Init physics
   local physics = require "physics"
   physics.start()
   physics.setGravity(0,0)

   -- Create some basic layers.
   --
   local layers = quickLayers( group, 
         "underlay",
         "world",
            { "circles", "player" },
         "overlay" )

   -- Create 5000 circles in random locations to act as stuff in our 'world'
   --
   for i = 1, 5000 do
      newCircle( layers.circles, 
                 mRand( -4 * fullw, 4 * fullw ),
                 mRand( -4 * fullh, 4 * fullh ),
                 { size = mRand( 20,40 ), alpha = 0.5,
                   fill = ssk.colors.pastelRGB( ssk.colors.randomRGB() ) } )
   end

   -- Create a joystick to move our 'player'
   --
   ssk.easyInputs.oneStick.create( layers.overlay , 
                                   { joyParams = { doNorm = true } } )

   -- Create a player with a 'enterFrame' listener to 'move' it.
   --
   local function enterFrame( self, event )  
      self:setLinearVelocity( self.vx, self.vy )
   end
   local player = newImageRect( layers.player, centerX, centerY, 
                                 "images/smiley.png", 
                                 { enterFrame = enterFrame, 
                                    vx = 0, vy = 0 }, {} )

   -- Add a joystick listener to the player
   function player.onJoystick( self, event ) 
      if( event.state == "off" ) then
         self.vx = 0
         self.vy = 0
      else
         self.vx = event.nx * 500 * event.percent/100
         self.vy = event.ny * 500 * event.percent/100
      end
   end; listen( "onJoystick", player )

   -- ***************************************
   -- Attach a Tracking Camera To Player + World
   -- ***************************************
   ssk.camera.tracking( player, layers.world, { disableSubPixel = true } )

end


return test


[TOPIC: post.html]
#7

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,093 posts
  • Corona SDK

The premise of a 'camera' is that you put all of your 'game objects' in a group or set of nested groups.

 

Then, you choose a 'focus object' and keep that object in the center of the screen (simplest case) by moving the 'camera' group every frame in the opposite direction the player moved prior to that frame.

 

 

i.e. If the player moves 5 pixels right, then the group is moved 5 pixels left.

 

This gives the impression the world is moving around the player.

 

camera.gif



[TOPIC: post.html]
#8

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 11 posts
  • Corona SDK

Yeah that is the function I wanted, thanks for the help. I will have to spend some time understanding the insertion of a camera though :huh:



[TOPIC: post.html]
#9

BulkOlav

[GLOBAL: userInfoPane.html]
BulkOlav
  • Observer

  • 11 posts
  • Corona SDK

I mean you'd have to set up your own:

  • scene management code to draw backgrounds as needed
  • scene managment code to remove images that are not in view any more to reduce memory usage on your device
  • .. more

Sorry, but this is not something that can be described or shown in just a few lines of description or code.  There are just too many ways to handle drawing an endless or large-but-limited sized world.

 

Personally, I suggest you consider a Tiled based solution like PonyTiled.

 

Warning: You're still going to have to learn and understand a bunch of stuff.  As well, you will need to modify the solution to suit your needs.

 

PS - Can you link a few YouTube  videos of games that you feel are representative of the kind of thing you are trying to do/make?  If we can see what you want to achieve, we might be able give better advice.

I think dead ops arcade is the game that best represents my plan. 

 

YouTube link: 

 

Ps skip to 37 sek.



[TOPIC: post.html]
#10

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,093 posts
  • Corona SDK

Looks like you're thinking about making a top-down omni-scroller.

 

Questions:

1. Is the map unlimited or does it have defined boundaries?

 

2. If the boundaries are defined, are they uniform (like a rectangular area) or arbitrary (may have any shape.)

 

3. Is the world all open or are there buildings you can enter?

 

4. Is your plan to make a shooter?

 

5. Do you plan to have a player character similar in mechanic to the one shown?

 

6. Do you intend to have multiple levels and/or area that are loaded separately?

 

7. How do you plan to control your character?  On screen joystick?  Twin sticks?  Buttons?  Other?

 

 

Note: Just in case, I did want to mention that the video you shared is actually 3D.  You said it was close, so I am assuming you're ignoring that facet of the video and that there will be no perspective.

 

If you want to make a game with perspective (say isometric or similar) then that is (quite) a bit more work.  I suggest first making a pure top-down game to learn about level creation, loading, etc.



[TOPIC: post.html]
#11

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,093 posts
  • Corona SDK

A long time ago, I helped put together a whole set of videos on 'top down' shooter design: https://www.youtube.com/playlist?list=PLQUSbLhyMnAqWcw-9DrKl2szm4_ii8pS1

 

The end result can be found here (game requires game pad to play because it was intended for desktop games):

https://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/ICanMakeThat/DesktopGames/TopDownShooter.zip

 

Here is a video of the game and other parts in the download (no sound):

 

PS - There are lot of other games here too:

 

https://github.com/roaminggamer/CoronaGeek/tree/master/Hangouts/ICanMakeThat



[TOPIC: post.html]
#12

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 395 posts
  • Corona SDK

@roaminggamer

Hi, don't want to hijack this thread so am happy to take it to a new one, but looking at that top down game I was wondering if it would be possible to do a split screen game so you could have 2 players on different areas of the map at the same time?

I would imagine that if it is possible it would probably be quite a bit of work?



[TOPIC: post.html]
#13

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,093 posts
  • Corona SDK

@Appletreeman,

 

I'll answer here, but you might want to start a new thread if any additional questions come out of this.

 

1. Yes, I believe it is possible.

 

2. You'd have to implement 'ghosting'.

 

3. A ghost (as I mean it) is a copy of an object.  i.e. The the original is visible in one viewport while the ghost is visible in another viewport.

 

4. I have actually done experiments with this in Corona.  I'll see if I can dig up code that still works.  (The experiment was long long ago.)

 

 Discussion taken to this thread: https://forums.coronalabs.com/topic/74031-split-screen-and-beyond/


Edited by roaminggamer, 09 October 2018 - 10:24 AM.



[topic_controls]
[/topic_controls]