Hey Everyone,
I am writing a twist on Super Hexagon (check out my post about it here: viewtopic.php?f=5&t=80361), and I am a bit stuck. So I've got the code for the table, as well as the table that *should* be drawing the blocks. I will attach a .love file so that you can take a look. So why is this mechanism not working? I only want it drawing the block if it's set to true in the worldData.spawn() call. Also, how would I be able to have it moving across the screen as well as making more at the same time? is there some way I can add it to some kind of buffer or something, and then it keeps the block drawn as long as it is on the screen. How would I go about doing this?
Attached will be a .love file. Here is the GitHub Repo: https://github.com/tom7tomm/SuperDoger
Thanks!
Adding graphics to a "buffer" drawing from table not working
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Adding graphics to a "buffer" drawing from table not working
- Attachments
-
- game.love
- (80.13 KiB) Downloaded 122 times
Check out my blog - The place to find out about the latest tech news! http://thegeekcircle.blogspot.co.uk/
Re: Adding graphics to a "buffer" drawing from table not wor
for the first problem : drawing from table not working
when you insert the table in worldData here is the table you insert (with the example segment piece) :
what you want is that
here is the code
for the second point : have it moving across the screen as well as making more at the same time
There are many solution, you can use canvas : create a canvas with the image of the segment and draw it at the x you want.
But it's not what I would suggest. What I would do is add an element x in the table of a segment initialised at 100 and at each update x=x+dx*dt with dx the velocity and dt the parametre return by love.update(dt). and then you draw it at love.window.getWidth() - x
when you insert the table in worldData here is the table you insert (with the example segment piece) :
Code: Select all
{1=1, 2=1, 3=true,..., 9=20}
Code: Select all
{segment=1, position=1, C1=true, ... , length=20}
Code: Select all
table.insert(worldData, {segment=segment, position=position, C1=C1, C2=C2, C3=C3, C4=C4, C5=C5, C6=C6, length=length})
There are many solution, you can use canvas : create a canvas with the image of the segment and draw it at the x you want.
But it's not what I would suggest. What I would do is add an element x in the table of a segment initialised at 100 and at each update x=x+dx*dt with dx the velocity and dt the parametre return by love.update(dt). and then you draw it at love.window.getWidth() - x
- Attachments
-
- game.love
- (80.13 KiB) Downloaded 96 times
Re: Adding graphics to a "buffer" drawing from table not wor
I am fairly sure I have got what you said, but it's not drawing anything. Why not?
Attatched will be a .love
Sorry to be a n00b
Thanks
Attatched will be a .love
Sorry to be a n00b
Thanks
- Attachments
-
- game.love
- (80.16 KiB) Downloaded 109 times
Check out my blog - The place to find out about the latest tech news! http://thegeekcircle.blogspot.co.uk/
Re: Adding graphics to a "buffer" drawing from table not wor
I added your world.loadData( ) function after line 24 in menu.lua, and it draws something now. The result is in attachment
- Attachments
-
- game_c1.love
- (94.57 KiB) Downloaded 100 times
Re: Adding graphics to a "buffer" drawing from table not wor
Thanks, didn't notice I wasn't calling that.
I have now added a bit more code to hopefully create the method of it moving across, but it does't like that I've put a variable in the worldData.spawn() call. Here is the code that it throws and attatched will be a .love.
I have now added a bit more code to hopefully create the method of it moving across, but it does't like that I've put a variable in the worldData.spawn() call. Here is the code that it throws and attatched will be a .love.
Code: Select all
function world.loadData()
segment11x = love.graphics.getWidth()
worldData.spawn(1, 1, true, true, true, false, true, true, 20, segment11x) --an example segment piece
end
function worldData.spawn(segment, position, C1, C2, C3, C4, C5, C6, segmentx) --what segment number it is, position in the segment, column 1-6, length of that position in the segment, the X of that segment
table.insert(worldData, {segment = segment, position = position, C1 = C1, C2 = C2, C3 = C3, C4 = C4, C5 = C5, C6 = C6, segmentx = segmentx})
end
- Attachments
-
- game.love
- (81.71 KiB) Downloaded 88 times
Check out my blog - The place to find out about the latest tech news! http://thegeekcircle.blogspot.co.uk/
Re: Adding graphics to a "buffer" drawing from table not wor
Well, i made segments move, but in a specific way. Here is a list of my changes to your code:
- First of all i changed line 19 of world.lua (which caused error) to:
Then, to avoid other errors, i replaced v.length to v.segmentx (it displays weird, but i kinda like it), because v.length was no more in worldData
Code: Select all
if v.segmentx < love.graphics.getWidth() and 0 < v.segmentx then
After running this game without errors, i decided to go further and to animate it. In order to do so, i added dt argument to love.update and world.update functions. I did so to connect movement with time
Then in world.update i added this cycle to make segments move:And finally i changed line 50 of world.lua to this:Code: Select all
for i, v in ipairs(worldData) do v.segmentx = v.segmentx - 100 * dt end
I removed the ninth argument (20) to make segment appear on the edge of the screenCode: Select all
worldData.spawn(1, 1, true, true, true, false, true, true, segment11x)
- Attachments
-
- game (1)_c1.love
- (96.66 KiB) Downloaded 109 times
Re: Adding graphics to a "buffer" drawing from table not wor
Thanks! This has really helped me in my development in the game.
Check out my blog - The place to find out about the latest tech news! http://thegeekcircle.blogspot.co.uk/
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests